Hi,
I would like to know how can I disable a WebDataGrid's cell dynamically. Let's say you have two columns, first is a checkbox and second is a text. So how can I disable editing of second column when the checkbox is unchecked and re-enable editing when checkbox is checked by the user? How to do it in javascript and code-behind?
Thank you,
Pascal
Hello Pascal,
Assuming you are using templates for the check box column and the checkbox is the only control in that template, something like the following can be used for your scenario.
Handle the EnteringEditMode event off of the CellEditing behavior.
<ig:EditingCore>
<Behaviors>
<ig:CellEditing>
<CellEditingClientEvents EnteringEditMode="enteringEditMode" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
The event handler may look like this:
function enteringEditMode(grid, eventArgs)
{
var cell = eventArgs.getCell();
if (cell.get_column().get_key() == "SecondColumn")
checkboxCell = cell.get_row().get_cellByColumnKey("FirstColumn");
if (!checkboxCell.get_element().firstChild.checked)
eventArgs.set_cancel(true);
}
How do I set it in code behind. For example, WebDataGrid1.Column[3].??? Thanks.
i think it would be WebDataGrid1.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings[2].ReadOnly=true;//for 3rd column