I order to set a cell in edit mode programmatically, I need use this API $("#grid").igGridUpdating("startEdit", rowIndex, columnIndex);. My question is how can we get the columnIndex at the runtime, not at design time? thanks.
Hello aschoi,
You can also use one of our internal functions for this:
$("#grid1_" + args.columnKey).data("columnIndex");
This code is more clear and also can be used.
It depends on the event used for this. For example if you use grid “cellClick” event the column index will be part of arguments returned by this event.
If you use external event (like button click) you should use custom function as follows:
function getColumnIndexByKey(columnKey) {var columns = $("#grid1").igGrid("option", "columns");var columnIndex = 0;for (var i = 0; i < columns.length; i++) {if (columns[i].hidden)continue;if (columns[i].key === columnKey) {return columnIndex;}columnIndex++;}return -1;}
You can use this function to get the column index by its key and then use the index (and row index) to put needed cell in edit mode.