Setting EpiUltraGrid to ReadOnly

Good afternoon,
I am trying to set a custom EpiUltraGrid to read only. I have already populated the grid with data from a BAQ. I set the grid to read only through code. But when I look at the grid, only the rows that are visible on the screen are set to read only. If I scroll down the grid one or more rows, then all rows below the ones initially displayed are not set to read only. If I rerun this function after scrolling down, then only the rows currently visible in the grid are set to read only, any rows above or below are editable. What the heck is going on here?

Here is the function where I set the grid data source and try to set it to read only.

private void CheckForCheckedOut()
	{
	//If this part/rev is checked out to the current user's eco group, then display warning. AND Show the ECO Grid!
		EpiDataView edv = (EpiDataView)this.oTrans.EpiDataViews["CallContextClientData"];
		string myUserString = edv.dataView[0]["CurrentUserId"].ToString();
		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();		
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("getPartRevOpECO");
		qeds.ExecutionParameter.Clear();
		qeds.ExecutionParameter.AddExecutionParameterRow("part", txtMyPart.Text, "nvarchar", false, Guid.NewGuid(), "A");
		qeds.ExecutionParameter.AddExecutionParameterRow("rev", revCombo.Text, "nvarchar", false, Guid.NewGuid(), "A");
		qeds.ExecutionParameter.AddExecutionParameterRow("ECOGroup", myUserString, "nvarchar", false, Guid.NewGuid(), "A");
		dqa.ExecuteByID("getPartRevOpECO", qeds);
		if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
		// This part is checked out! Flag the screen and show the warning.
			lblCheckedOutWarning.Visible = true;
			ecoUltraGrid.Visible=true;
			ecoUltraGrid.DataSource = dqa.QueryResults.Tables["Results"];
			oTrans.NotifyAll();
			ecoUltraGrid.ReadOnly = true; // Set grid to read only! Rows below initial screen are not readonly!
			ecoUltraGrid.Refresh();
		}
		else
		{
			lblCheckedOutWarning.Visible = false;
			ecoUltraGrid.Visible=false;
			oTrans.NotifyAll();
		}

	}

In the attached GIF you can see me demonstrate the issue. The table in the middle is the custom epi ultra grid that I want to be completely read only. Instead you can see only the visible rows are set to read only.

Here’s some snippets that might help get you going

//UltraGrid Read Only Techniques
//This loops through all columns in the band and de-activates if the visible position is the first one
foreach(var col in grdAllocations.DisplayLayout.Bands[0].Columns)
{				

  if(col.Header.VisiblePosition != 1)
  {
    col.CellActivation = Activation.Disabled;	
  }			
}
//this loops through the bands and inactives the entire band. I had little luck using the captions to filter
foreach(var col in grdAllocations.DisplayLayout.Bands)
{
  //!col.Header.Caption.ToUpper().Contains("Allocate")
  //MessageBox.Show("VP: " + col.Header.VisiblePosition.ToString()+ "\n" + "Name: " +col.Header.Caption.ToString());
  if(col.Header.VisiblePosition != 1)
  {					
    col.Override.AllowUpdate = DefaultableBoolean.False;
  }			
}

//this sets the column read only property on the datatable level before binding to a grid
//again, I used the ordinal not the caption to filter
foreach(DataColumn c in mergedDataSet.Tables[0].Columns)	
{			
  //msg += "P: " + c.Ordinal.ToString()+  " Caption: " +c.Caption.ToString() + " ColumnName: " + c.ColumnName.ToString() + "\n";
  if(c.Ordinal != 14)
  {	
    c.ReadOnly = true; 		
  }	
}
1 Like

What @Aaron_Moreng said should work,
However,

I would recommend using a BAQDataView with pub / sub to get you a closer/more “native” functionality and then you can manage the read-onlyness with standard RowRules or ExtendedProperties. (And less code potentially)

3 Likes

Not to hijack this, but it sure would be nice if Kinetic has this built in :wink:

Which Part?
Kinetic App Studio has a LOT… of Features… :yum:

Sometimes simply setting a column readonly does work because of the epi magic in the background and you may need to employ use of the ExtendedProps in some cases.

This sounds like a good idea. Can you point me to a bit more info on how to set that up?

Thank you! I love code snippets!

2 Likes

I don’t believe this will work unless you maintain the setting inside an EpiViewNotification as Epicor will keep trying to change it according to the fields/rows settings as part its EpiMagic or their ExtendedProperties. AFAIK The only way to keep the grid set to ReadOnly is to keep updating the EpiUltraGrid’s setting within an EpiViewNotification.

I did something similar here