I have WebHierarchicalDataGrid. In the root band, there is a check box (BoundCheckBoxField). There is also a hidden column that controls whether or not the row should be editable.
How can I dynamically (row-by-row) set whether or not the check box is editable?
I am aware of the CellEditing behavior, but that can only be set for the whole column, not for specific rows/cells. I have also seen in other posts where it is recommended that the EnteringEditMode client side event be handled and eventArgs.set_cancel can be used to prevent the edit from beginning. That's fine for BoundDataField columns, but the EnteringEditMode event is never fired for the check box column. I have tried handling the grid click event and am able to detect the checkbox column and check the data I have in another column in the row, but the set_cancel does nothing to prevent the box from being toggled. Furthermore, it looks like the check box is toggled before the event is even raised.
Is there another client side event I can use to prevent a check box cell from being edited?
Hello Nick,
In order to disable the checkbox you can use CellValueChanging event rather than EnteringEditingMode. For example:
<Behaviors> <ig:EditingCore EnableInheritance="True" Enabled="true"> <EditingClientEvents CellValueChanging="WebHierarchicalDataGrid1_Editing_CellValueChanging"/> <Behaviors> <ig:CellEditing EnableInheritance="true"> <EditModeActions EnableOnActive="True" MouseClick="Single" /> </ig:CellEditing> </Behaviors> </ig:EditingCore> </Behaviors>
And depending on the custom logic you can effectively cancel a checkbox of been checked/unchecked:
function WebHierarchicalDataGrid1_Editing_CellValueChanging(sender, eventArgs) { //my custom logic eventArgs.set_cancel(true); }
Note that if you set in the WebHierarchicalDataGrid's Behaviors with the EnableInheritance="True", this affect all the child levels. If you want to further modify a specific child logic you can again set it in that child's Behaviors and modify it.
Sincerely,NickEntry-Level Software Developer
Is there a way to check to see if the column type is a checkbox inside the function? My EnteringEditMode is working fine on all fields except the checkbox fields. But, when I added in the CellValueChanging, it's causing problems with what was already working in the EnteringEditMode.
Hello Angela,
The same question is discussed in this forum topic.Sincerely,NickEntry-Level Software Developer