在Dojo Gridx中使用onCellWidgetCreated(向单元格添加按钮)

时间:2015-08-21 21:26:18

标签: javascript dojo dojo.gridx gridx

我尝试在Gridx的最后一列添加一个按钮,但是,按钮没有显示,而在其他表数据上方,网格只是说“正在加载......”。

enter image description here

需要并声明Cell Widget,设置widgetInCell并添加onCellWidgetCreated函数。使用alert替换onCellWidgetCreated函数时,会显示每行的警报消息,并且“loading ...”消失。我的感觉是onCellWidgetCreated函数错了吗?

我的代码如下所示,当它与Gridx网站上的一些示例进行比较时,我找不到问题。

require([
    "gridx/Grid",
    "gridx/core/model/cache/Sync",
    "dojo/store/Memory",
    "dojo/domReady!",
    "gridx/modules/CellWidget",
    "dijit/form/Button"
], function(Grid, Cache, Memory,Button,CellWidget,domConstruct){
        var store = new Memory({
            idProperty:"CategoryID",
            data: jsondata
        });

        var grid = new Grid({
            id:"gridId",
            store: store,
            cacheClass: Cache,
            structure: [
                { 
                    id: "0", 
                    field: "CategoryID", 
                    name: "Kategorie (ID)", 
                    width: "100px" 
                },
                { 
                    id: "1", 
                    field: "CategoryName", 
                    name: "Kategoriename" 
                },
                { 
                    id: "2", 
                    field: "Attributes", 
                    name: "Attribute" 
                },
                { 
                    id: "3", 
                    field: "Actions", 
                    name: "Aktion", 
                    widgetsInCell: true,
                    onCellWidgetCreated: function(cellWidget, column){
                        var btn = new Button({
                            label: "Click me!"
                        });
                        btn.placeAt(cellWidget.domNode);
                    }
                }
            ],
            modules: [
                CellWidget
            ]
        });
        grid.placeAt("aGrid");
        grid.startup();


    }
);

1 个答案:

答案 0 :(得分:0)

我遇到了VirtualVScrolling的另一个问题,发现这是由于一个有缺陷的gridx css文件,其中包含一个自定义布局。 使用标准css文件时,“onCellWidgetCreated”也适用于我。