Dijit表格选择

时间:2013-02-24 20:44:27

标签: dojo

我对此路径上的dgrid-master / editor_more_widgets.html测试文件有疑问:

https://github.com/SitePen/dgrid/blob/master/test/editor_more_widgets.html

也许你应该下载整个包来查看文件。无论如何,有没有办法修复“选择商店”列,以便它显示标签而不是值,如“FilteringSelect商店”列?

1 个答案:

答案 0 :(得分:0)

我为此创建了一个自定义插件。关键部分是renderCell函数:

define([
    "dojo",
    "sb",
    "put-selector/put",
    "dgrid/editor",
    "dijit/form/Select"
], function(dojo, sb, put, editor, Select){
    dojo.global.starbug.grid.columns = dojo.global.starbug.grid.columns || {};
    dojo.global.starbug.grid.columns.select = function(column){

        //populate the cell with the label or value
        column.renderCell = function(object, value, cell, options, header){
            items = column.editorInstance.getOptions();
            for (var i in items) {
                if (value == items[i].value) value = items[i].label;
            }
            put(cell, 'span.'+value.replace(/ /g, '-').toLowerCase(), value);
        };

        column.editorArgs = {
            style:'width:100%',
            labelAttr:'label',
            store:sb.get(column.from, 'select')
        };

        column = editor(column, Select, "dblclick");

        return column;
    };
});

请注意sb是我用来提供商店的自定义模块。你可以相应地修改它。