我尝试在我的 Gridx 的最后一列中添加一个按钮,但是,该按钮未显示,并且在其他表数据上方,网格仅显示“正在加载...”。
需要并声明了 Cell Widget,设置了 widgetInCell 并添加了 onCellWidgetCreated 函数。将 onCellWidgetCreated 函数替换为 alert 时,每行都会显示一条警告消息,并且“正在加载...”消失。我的感觉是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();
}
);