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

一曲冷凌霜 提交于 2019-12-12 02:46:26

问题


I try to add a button to the last column of my Gridx, however, the button is not shown and above the other table data the grid just says "loading...".

Cell Widget is required and declared, widgetInCell is set and onCellWidgetCreated function added. When replacing the onCellWidgetCreated function with alert, an alert message for each row is shown and the "loading..." disappears. My feeling is that the onCellWidgetCreated function is wrong?

My code looks like the following and when comparing it against some examples on the Gridx website I cannot find the problem.

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:


I came across anotheer problem with VirtualVScrolling and found out that this was due to a defective gridx css file which contained a custom layout. When using the standard css file, "onCellWidgetCreated" worked for me as well.



来源:https://stackoverflow.com/questions/32149477/use-of-oncellwidgetcreated-in-dojo-gridx-to-add-button-to-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!