Vikram
Vikram

Reputation: 51

How to get column index from column name in dojo Enhanced grid?

How can i get the column index from the column name in the dojo enhanced grid ???? Any help would be appreciated

Upvotes: 1

Views: 2993

Answers (1)

kyerie
kyerie

Reputation: 106

I don't know if this is what you are looking for but my brute force way of knowing the "field" attribute of the grid and determining the index of the column is like this:

var retrieveFieldIndexByFieldName = function(fieldName) {
    var exGrid = dijit.byId("grid1"); // assuming grid1 is your grid
    var index = -1;
    dojo.forEach(exGrid.layout.cells, function(cell,idx) {
        if (cell.field == fieldName) {
            index = idx;
            return false; // please do check if return false is needed here
            // I actually forgot if this one was needed to exit the forEach loop of dojo
        }
    }
    return index;
}

so there. hope this helps.

Upvotes: 3

Related Questions