0
我嘗試將一個按鈕添加到Gridx的最後一列,但是,該按鈕未顯示,而其他表格數據上方的網格僅顯示「加載」。 ..「。在Dojo Gridx中使用onCellWidget創建(將按鈕添加到單元格)
細胞的widget是必需的,聲明,widgetInCell被設置和onCellWidgetCreated功能加入。使用alert替換onCellWidgetCreated函數時,會顯示每行的警報消息,並且「加載...」消失。我的感覺是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();
}
);