Javascript 如何让驻留在cellWidgets中的dojo gridx dojo小部件自动写入存储?

Javascript 如何让驻留在cellWidgets中的dojo gridx dojo小部件自动写入存储?,javascript,dojo,dojo.gridx,Javascript,Dojo,Dojo.gridx,在具有可编辑:true的文本单元格上,我没有问题写入存储-单元格自动写入存储,但我的CellWidget没有写入存储 下面是我的一段代码(注释掉的最上面的第2-5行是我没有运气尝试的其他代码): 如何让cellWidgets中的dojo小部件写入gridx存储?通过正确设置编辑模块,可以将任何cellWidget自动保存到存储。请参阅本文档: 当网格包含编辑模块时,这并不意味着所有单元格都可以立即编辑。相反,我们必须告诉网格哪些列包含可编辑字段。为此,我们将名为editable的列属性设置为tr

在具有
可编辑:true
的文本单元格上,我没有问题写入存储-单元格自动写入存储,但我的CellWidget没有写入存储

下面是我的一段代码(注释掉的最上面的第2-5行是我没有运气尝试的其他代码):


如何让cellWidgets中的dojo小部件写入gridx存储?

通过正确设置编辑模块,可以将任何cellWidget自动保存到存储。请参阅本文档:

当网格包含编辑模块时,这并不意味着所有单元格都可以立即编辑。相反,我们必须告诉网格哪些列包含可编辑字段。为此,我们将名为editable的列属性设置为true。默认值为false,这意味着该列中的单元格不可编辑

编辑单元格时,将在屏幕上单元格的位置创建Dojo小部件(Dijit)的新实例。此小部件负责显示当前值并允许用户更改该值。默认情况下,使用的小部件是dijit.form.TextBox的实例,但可以使用不同的小部件类型。名为editor的属性应设置为要使用的Dijit类的字符串名称。记住,如果使用此类类型的AMD include,请定义它。另一个名为editorArgs的列属性可用于向编辑器中命名的小部件提供属性。editorArgs属性是具有以下属性的对象:

道具(字符串)
-在Dijit小部件上定义的属性集
fromEditor(函数(storeData、gridData))
toEditor(函数(storeData、gridData、cell、editor))
-调用函数填充编辑器小部件。editor参数是对用于编辑单元格的Dijit小部件的引用。
约束(对象)
-传递给编辑器的其他属性。
useGridData(布尔)
-编辑器应该从存储区还是从网格中获取数据?默认值为false,表示使用存储数据。如果提供了ToEdit,则不使用此属性。
valueField(String)
-保存值的编辑器的属性。这通常是默认值

单元格编辑完成后,输入的数据将写回存储区。我们可以通过使用我们自己的逻辑提供一个要调用的函数来应用更改,从而改变实现这一点的方式。此属性是customApplyEdit,它是一个带有签名函数(单元格,值)的函数。代码负责将单元格的值设置为作为参数传入的值


查看此JSFIDLE:

您试图手动写入存储的注释代码是否有问题?我正在尝试让cellWidget中的dojo小部件自动写入存储。我发现答案似乎在编辑模块中(顶部附近注释掉的代码)。我目前正试图修改我的代码,让我的cellWidget自动写入商店。我无法让它工作……你能做一把小提琴让我看到你所有的代码吗?@Richard再次感谢你的帮助,但我正在继续。我用另一种方式解决了它。我将发布一个答案,说明编辑模块是解决问题的正确方法。
            { 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>";
                }
            },
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);
});