Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
975
how to get the column index dynamically
posted

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.

Parents
  • 15979
    Suggested Answer
    posted

    Hello aschoi,

    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.

Reply Children
No Data