I have a webdatagrid, it has a number of columns, 2 are editiable, the rest are read only...
When selection is turned on, pressing tab puts focus on the readonly cells, i would like to prevent this from happening and only "tab" to the editable cells.
Some help?
Hello Daryl007,
Thank you for posting in the community.
I am attaching a sample illustrating how activation may be skipped (disabled) for readonly cells in a grid allowing tabbing through only the editable cells. Note that this scenario also sets the focus on the nearest editable cell, once a readonly cell is clicked. Below is the relevant javascript code used:
function WebDataGrid1_Activation_ActiveCellChanging(sender, eventArgs) { //if you click on the non editable cell, cancel the event and return so nothing happens if (typeof event != 'undefined' && event.type == "mousedown" && eventArgs.getNewActiveCell().get_column().get_key() == "SupplierID") { eventArgs.set_cancel(true); return; } var column = eventArgs.getNewActiveCell().get_column(); var columnKey = column.get_key(); var cellEditing = sender.get_behaviors().get_editingCore().get_behaviors().get_cellEditing(); var columnSetting = cellEditing.get_columnSettingFromKey(columnKey); if (columnSetting != null && columnSetting.get_readOnly()) { eventArgs.set_cancel(true); var cellIndex = eventArgs.getNewActiveCell().get_index(); //logic to jump over multiple readonly cols var nextCell = eventArgs.getNewActiveCell().get_row().get_cell(cellIndex + 1); var nextCellKey = nextCell.get_column().get_key(); while (cellEditing.get_columnSettingFromKey(nextCellKey)) { nextCell = nextCell.get_row().get_cell(nextCell.get_index() + 1); nextCellKey = nextCell.get_column().get_key(); } sender.get_behaviors().get_activation().set_activeCell(eventArgs.getNewActiveCell().get_row().get_cell(nextCell.get_index())) } //Add code to handle your event here. }
Hope this helps. Please do not hesitate to contact me if you have any questions.