Results 1 to 3 of 3

Thread: How to find a grid column based on dataIndex

  1. #1
    Sencha User
    Join Date
    Aug 2011

    Default How to find a grid column based on dataIndex

    Earlier today I almost asked how to find a grid column based on dataIndex. I'd searched the docs, the forums, and Google, and couldn't find the answer.

    Then I remembered Ext.Array.pluck (and indexOf) and devised my own little function, see below. Am just sharing it here if anybody else ever needs something such as this in the future, so they won't search in vain like I did. Or am I duplicating something that exists in the framework somewhere already?

    function findGridColumnByDataIndex(grid, dataIndex) {
        var gridColumns = grid.columns,
            gridDataIndices = Ext.Array.pluck(grid.columns, 'dataIndex');
        return gridColumns[Ext.Array.indexOf(gridDataIndices, dataIndex)];
    Once we iron out all the bugs, we'll be running on flat bugs

  2. #2
    Sencha User edspencer's Avatar
    Join Date
    Jan 2009
    Palo Alto, California


    Only thing to be aware of here is that more than one column can use the same dataIndex. Typically assigning an id to the column is the best way to handle this so you know you've got the column you wanted
    Ext JS Senior Software Architect
    Personal Blog:

  3. #3


    I'm using Ext JS 6.2 and I use the following code:
    myGrid.getColumnManager().getHeaderByDataIndex('my field name');

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts