如何从dojo增强网格????中的列名获得列索引如有任何帮助,不胜感激
我不知道这是不是你想要的,但是我的蛮力方法知道网格的"field"属性并确定列的索引是这样的:
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;
}
。