问题描述
我尝试添加一个按钮到Gridx的最后一列,但是,该按钮没有显示,并且在其他表格数据之上,网格只是说加载...。
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...".
需要并声明单元格小部件,widgetInCell已设置,并添加onCellWidgetCreated函数。当使用alert替换onCellWidgetCreated函数时,会显示每行的警告消息,loading ...消失。我的感觉是onCellWidgetCreated函数是错误的?
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?
我的代码看起来像以下内容,当与Gridx网站上的一些示例进行比较时,我找不到问题。 p
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();
}
);
推荐答案
我遇到了VirtualVScrolling的anotheer问题,并发现这是由于包含自定义布局的gridx css文件有缺陷。
当使用标准的css文件时,onCellWidgetCreated也适用于我。
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.
这篇关于在Dojo Gridx中使用onCellWidgetCreated(将按钮添加到单元格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!