Difficulty making the whole grid view read only in Order Entry?

In Order Entry, there is a Lines Detail tab at the bottom with an UltraGrid of the lines. Whether the rows are editable depends on the editability of the field. I want this whole grid to be read only. I can’t do this in the Grid Properties because it doesn’t save. So I’ve tried this on the view initialize:

private void makeGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGrid grid)
{
	foreach (var column in grid.DisplayLayout.Bands[0].Columns)
	{
		column.CellActivation = Infragistics.Win.UltraWinGrid.Activation.Disabled;  // Also tried ActivatedOnly;
	}
}

This doesn’t do anything. Furthermore, it looks like all the columns are already set to ActivatedOnly, which should not be editable. Any ideas?

Also tried:

grid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False;

And

column.CellActivation = Infragistics.Win.UltraWinGrid.Activation.NoEdit; 
column.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.CellSelect

What are you using for a datasource in your grid?
I’m guessing that the ds is not read only and will override your custom properties for the grid.

1 Like

It’s the default datasource on the Order Entry screen for the lines. It appears to be overriding any settings. I just want to make the grid read-only, not the fields themselves.

another way, use CellChange event… when user types data, throw error message saying “not allowed to edit grid”.

Documentation Archives | Infragistics

I wonder if instead you could use a BAQ and then a DynamicQuery as a grid datasource?
Or a dashboard & sheet wizard?

1 Like

Yet another solution would be to hide the the whole panel/grid and replace it with a BAQ that you’re written. (which I see @bordway just suggested).

Mark W.

Isn’t there an option to make each column in a grid read only or hidden on the grid control itself? The other technique, since it’s bound to a dataview column is to set the extended properties of the columns displayed to Read Only…

The first option doesn’t work if it’s databound. See here: Read only in grid - ERP 10 - Epicor User Help Forum

The second option makes the whole field read only anywhere it appears in the customization doesn’t it? That’s not the goal.

Sounds like the datasource is overriding the grid properties. Maybe use the brute force approach and call this on RowChange of the datasource:

void DisableCols(EpiUltraGrid grid)
{
	foreach(DataColumn c in ((DataTable)grid.DataSource).Columns)
	{
	c.ExtendedProperties["ReadOnly"]=true;
	}
}

I get an error at RunTime: Unable to cast object of type ‘System.Windows.Forms.BindingSource’ to type ‘System.Data.DataTable’. Do you know of a fix?

Oh sorry try this:

BindingSource bs = (BindingSource)grid.DataSource; 
DataTable myTable = (DataTable) bs.DataSource;
foreach(DataColumn c in myTable.Columns)
	{
	c.ExtendedProperties["ReadOnly"]=true;
	}

Better yet follow @prakash advice since the datasource is a DataView anyway

1 Like

((DataView)grid.DataSource).Table.Columns