Hey there,
During the MVC construction of the grid, I have a column called "Classification" that is readonly. I also subscribe to the event 'iggridupdatingeditcellstarting' to make runtime decisions about the editors. Well a new scenario came up where depending on one of the conditions from another column, the "Classification" will need to have the property of readonly set to false instead of true which was originally set during the page rendering.
I can grab the data of the grid, but then I have to drill into the set of options to switch the value and is wondering if there is a more elegant or object oriented way of doing this:
$('.selector').on('iggridupdatingeditcellstarting', function (e, ui) { var options = $(ui.owner.element).data('igGrid').options; options.features[0].columnSettings[6].readonly = false; // columnSettings[6] = 'Classification'}
Since this column's readonly property is set to true, it will not raise the 'iggridupdatingeditcellstarting' event for that editor. But I want it too. Typically it won't just under certain conditions but I'm having trouble with the API in making it do what I want.
In razor it is set from the Grid's Updating Feature, then under Column Setting the column is referenced by its key then marked as readonly.
Thanks,
I've had the weekend to think about this and I came up with this alternate solution instead:
Classification should rarely be editable. This is driven by columns in the grid where the editCellStarting event fires first. Since Classification is driven off of these other columns (By driven I mean the datasource -- not user selected value), I have removed the readonly property from the razor code but the editCellStarting event will be return false for Classification about 95% of the time. Thus making it look like it is readonly unless certain conditions are met.
This solves the issue of setting readonly property and gives the user the correct impression of what is editable and what isn't.
Hi Daniel,
You can set column readOnly property at runtime, but you should carefully pick the right event to do this. editCellStarting is not a good candidate, because it won't fire for "Classification" column. In your case you should chose an event (probably editCellEnded) of the column on which "Classification" column depends. This way you'll get the editCellStarting for "Classification" column.
It will be good if you provide more information on the column on which "Classification" column depends(for example: dataType, editorType and so on), so I can make a more concrete suggestions on how you can resolve your issue.
Best regards,
Martin Pavlov
Infragistics, Inc.