0

次のパスにある dgrid-master/editor_more_widgets.html テスト ファイルについて質問があります。

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

ファイルを表示するには、パッケージ全体をダウンロードする必要があります。とにかく、「Select Store」列を修正して、「FilteringSelect Store」列のように、値ではなくラベルを表示する方法はありますか?

4

1 に答える 1

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は、ストアを提供するために使用したカスタム モジュールです。それに応じて変更できます。

于 2013-04-14T21:10:59.013 に答える