I am using a RadGrid in batch edit mode with 4 editable columns.
This is working fine but I need to optionally set the columns as non-editable depending on which user is editing the screen.
eg. user A can edit all columns but user B can only edit 2 and user C only 1 column.
Is there a way to make an editable column non-editable when drawing the grid.
4 Answers, 1 is accepted
You can achieve this requirement using the ReadOnly property of the columns. Access the columns during the DataBinding or PreRender event handler of the grid and depending on the logged User, you can change their ReadOnly property to true:
I hope this will prove helpful.
I tried the following:
protected void RadGrid1_PreRender(object sender, EventArgs e)
GridTableView masterTable = (sender as RadGrid).MasterTableView;
GridColumn productNameColumn = masterTable.GetColumnSafe("ProductName") as GridColumn;
But 'productNameColumn' does not have a readonly property, am I missing something?
Yes, this approach is correct. However, you need to use a GridBoundColumn:
This if condition will also return true for column types inheriting GridBoundColumn like GridNumericTextBox. You can find a table with this information here:
Thank you - this worked (altho I had to use a GridTemplateColumn):
GridTemplateColumn productNameColumn = masterTable.GetColumnSafe("ProductName") as GridTemplateColumn;
This does break the 'onBatchEditCommand' as the item is removed from the 'oldValues/newValues' lists,
however I should be able to work round this with some extra code to pull the original values.
Thank you for your help