在具有editable: true的文本单元格上,我没有问题要写入存储区--单元格自动地写入存储区,但我的cellWidgets没有一个写入存储区。
下面是我代码的一个片段(注释掉的第2-5行是我尝试过的其他一些没有成功的代码):
{ id: 'identColumnId', field: 'identColumn', name: 'Ident', width: '77px',
// editable: true,
// editor: 'dijit/form/ComboButton',
// editorArgs:{
// props:'store: identMemStore'
// },
widgetsInCell: true,
navigable: true,
setCellValue: function(one,two,cellWidget){
var rowIndex = cellWidget.cell.row.id;
var toggle = identMemStore.get(rowIndex).identColumn;
if (toggle)
{
this.identColumn.set('label', "Override");
this.identColumn.set("checked",false);
}else
{
this.identColumn.set('label', "Use Input");
this.identColumn.set("checked",true);
}
},
getCellWidgetConnects: function(cellWidget, cell){
// return an array of connection arguments
return [
[cellWidget.identColumn, 'onClick', function(e){
var rowIndex = cellWidget.cell.row.id;
var curValue = identMemStore.get(rowIndex).identColumn;
if (curValue === true){
cellWidget.identColumn.set('label', "Use Input");
cellWidget.identColumn.set("checked",true);
// Write to store manually...
// identMemStore.data[rowIndex-1].identColumn = false;
} else if (curValue === false){
cellWidget.identColumn.set('label', "Override");
cellWidget.identColumn.set("checked",false);
// Write to store manually...
// identMemStore.data[rowIndex-1].identColumn = true;
} else {
console.log("ERROR");
}
}]
];
},
decorator: function(){
return "<button data-dojo-type='dijit/form/ToggleButton' data-dojo-attach-point='identColumn' ></button>";
}
},此外,我还设置了代码,以便在将数据写入存储区后捕获单元格编辑上的更改。同样,我的文本单元格工作得很好,下面的代码被执行,但是我的其他dojo小部件不会写入商店,因此不会启动以下代码,这些代码是在编辑完成和存储被写入之后执行的。
identGridx.edit.connect(identGridx.edit, "onApply", function(cell, success) {
var item = cell.row.data();
var id = cell.row.id;
console.log('Row with ID ' + id + ' is modified. New value: ' + item);
});如何将cellWidgets中的dojo小部件写入gridx商店?
发布于 2015-05-19 21:16:50
通过编辑模块的正确设置,您可以自动将任何cellWidget保存到存储区。请参阅以下文档:Dojo编辑模块
当网格包括编辑模块时,这并不意味着所有单元格都是可立即编辑的。相反,我们必须告诉网格哪些列包含可编辑字段。为此,我们将名为“可编辑”的列属性设置为true。默认值为false,这意味着该列中的单元格不可编辑。
在编辑单元格时,将在屏幕上单元格的位置创建Dojo小部件(Dijit)的新实例。此小部件负责显示当前值,并允许用户更改该值。默认情况下,使用的小部件是dijit.form.TextBox的一个实例,但是可以使用不同的小部件类型。调用编辑器的属性应该设置为要使用的Dijit类的字符串名称。如果使用此类类型,请记住定义AMD包含。另一个名为editorArgs的列属性可用于向编辑器中命名的小部件提供属性。editorArgs属性是以下属性的对象:
调用props (String) -定义在Dijit fromEditor (function(storeData, gridData)) toEditor (function(storeData, gridData, cell, editor)) -函数上的属性集来填充编辑器小部件。编辑器参数是对用于编辑单元格的Dijit小部件的引用。constraints (Object) -传递给编辑器的其他属性。useGridData (Boolean) --编辑器是否应该输入来自商店或网格的数据?默认值为false,这意味着使用存储数据。如果提供了toEditor,则不使用此属性。valueField (String) -保存该值的编辑器的属性。这通常是值,这是默认值。
当单元格的编辑完成后,输入的数据将被写回存储区。我们可以通过提供一个要调用的函数来使用我们自己的逻辑来应用更改来改变这种变化的实现方式。它的属性是customApplyEdit,它是一个带有签名函数(单元格,值)的函数。代码的责任是将单元格的值设置为作为参数传入的值。
看看这个小玩意:工作实例
https://stackoverflow.com/questions/30216488
复制相似问题