如何从dojo增强网格中的列名获取列索引? 任何帮助将不胜感激
答案 0 :(得分:3)
我不知道这是否是您正在寻找的东西,但我知道网格的“字段”属性和确定列的索引的强力方式是这样的:
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;
}
所以那里。希望这有帮助。