【问题标题】:How to get column index from column name in dojo Enhanced grid?如何从dojo增强网格中的列名获取列索引?
【发布时间】:2012-01-04 12:05:43
【问题描述】:

如何从 dojo 增强网格中的列名获取列索引 ???? 任何帮助将不胜感激

【问题讨论】:

    标签: dojox.grid dojox.grid.datagrid


    【解决方案1】:

    我不知道这是否是您要查找的内容,但是我知道网格的“字段”属性并确定列索引的蛮力方式是这样的:

    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;
    }
    

    就是这样。希望这会有所帮助。

    【讨论】:

    • 感谢 kyerie 的快速回复。我一直在寻找一些直接的方法来获得它。认为没有直接的方法可以得到它,我将采用上述方法。再次感谢..
    猜你喜欢
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2013-01-27
    • 2015-10-02
    • 2023-04-08
    • 2018-06-01
    相关资源
    最近更新 更多