Reputation: 51
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
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