dojo Dijit表单选择

4dc9hkyq  于 2022-12-20  发布在  Dojo
关注(0)|答案(1)|浏览(311)

我有一个关于此路径下的dgrid-master/editor_more_widgets. html测试文件的问题:

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

也许你应该下载整个包来查看文件。无论如何,有没有办法修复“选择存储”列,使其显示标签而不是值,就像“筛选选择存储”列所做的那样?

n3schb8v

n3schb8v1#

为此我创建了一个自定义插件,关键部分是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是我用来提供商店的定制模块,您可以相应地修改它。

相关问题