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

use of onCellWidgetCreated in Dojo Gridx (to add button to cell)

我尝试将一个按钮添加到我的 Gridx 的最后一列,但是,该按钮没有显示,并且在其他 table 数据上方,网格只是显示 "loading...".

需要并声明 Cell Widget,设置 widgetInCell 并添加 onCellWidgetCreated 函数。当用警报替换 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();


    }
);

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