Skip to content

Infragistics Community Forum / Web / Ignite UI for jQuery / how to get the column index dynamically

how to get the column index dynamically

New Discussion
Michael Xu
Michael Xu asked on Apr 17, 2013 3:56 PM

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.

Sign In to post a reply

Replies

  • 0
    Alex E
    Alex E answered on Apr 12, 2013 1:48 PM

    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.

    • 0
      Alex E
      Alex E answered on Apr 17, 2013 3:56 PM

      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.

       

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Michael Xu
Favorites
0
Replies
2
Created On
Apr 17, 2013
Last Post
13 years, 7 months ago

Suggested Discussions

Tags

Created by

Created on

Apr 17, 2013 3:56 PM

Last activity on

Apr 17, 2013 3:56 PM