Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/366.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ExtJS传递store.sync()上的所有字段_Javascript_Ajax_Extjs - Fatal编程技术网

Javascript ExtJS传递store.sync()上的所有字段

Javascript ExtJS传递store.sync()上的所有字段,javascript,ajax,extjs,Javascript,Ajax,Extjs,在ExtJS 6.5.0中,我创建了一个存储和一个可编辑的gridpanel: Ext.define('StateStore',{ extend: 'Ext.data.Store', alias: 'store.stateStore', storeId : 'StateStore', fields: ['Id', 'Name', 'SortIndex'], autoLoad : true, proxy: { type : 'aj

在ExtJS 6.5.0中,我创建了一个存储和一个可编辑的gridpanel:

Ext.define('StateStore',{
    extend: 'Ext.data.Store',
    alias: 'store.stateStore',
    storeId  : 'StateStore',
    fields: ['Id', 'Name', 'SortIndex'],
    autoLoad : true,

    proxy: {
        type : 'ajax',
        api  : {
            create  : undefined,
            read    : '/kanban/states/read/' + kanbanId,
            update  : '/kanban/states/update/' + kanbanId,
            destroy : undefined
        },
        writer : {
            type        : 'json',
            allowSingle : false
        }
    }
});


var StateList = Ext.create({
    xtype : 'gridpanel',
    selModel: 'cellmodel',
    title : 'Manage States',
    store : {
        type: 'stateStore'
    },
    plugins: {
        ptype: 'cellediting',
        clicksToEdit: 1
    },
    columns: [
        {
            text: 'ID',
            dataIndex: 'Id',
            flex: 1
        },{
            text: 'Name',
            dataIndex: 'Name',
            flex: 2, 
            editor: {
                field: {
                    type: 'textfield',
                    allowBlank: false
                }
            }
        },
        { 
            text: 'SortIndex',
            dataIndex: 'SortIndex',
            flex: 1,
        }
    ],
});
当用户完成编辑并单击“保存”时,将调用store.sync()函数,但它只将修改后的记录和字段传递给服务器。我使用
record.dirty=true
强制它通过所有记录,但未修改的字段仍然没有通过

为什么我要通过所有记录和字段?因为我想删除现有记录,并在每次更新时创建新记录。因此,我不需要单独处理创建/更新/删除。只有几个条目,因此性能不是问题


一种解决方案是使用
Ext.Ajax()
而不是
sync()
,我想知道有没有更好的解决方案?

使用
writealfields:true
配置编写器


相关。

使用
writealFields:true
配置编写器


相关。

是。将writeAllFields设置为true即可。在以前的版本中,默认设置为true,但对于6.5.0,必须手动设置。
true
将记录中的所有字段写入服务器。如果设置为false,它将只发送已修改的字段。这仅适用于
记录中的
字段
。它不会将
所有记录
发送到服务器。@Shahbaz不确定您做了什么,但自从我在v4.2.1中开始使用ExtJS以来,我不得不手动设置它。@Alexander看起来我们都是从4.2开始的,但经历了不同的行为。你仍然可以查看文档。它说默认为:True您可以使用该属性管理单个字段,而不是整个模型。是的。将writeAllFields设置为true即可。在以前的版本中,默认设置为true,但对于6.5.0,必须手动设置。
true
将记录中的所有字段写入服务器。如果设置为false,它将只发送已修改的字段。这仅适用于
记录中的
字段
。它不会将
所有记录
发送到服务器。@Shahbaz不确定您做了什么,但自从我在v4.2.1中开始使用ExtJS以来,我不得不手动设置它。@Alexander看起来我们都是从4.2开始的,但经历了不同的行为。你仍然可以查看文档。它表示默认值为:True您可以使用该属性管理单个字段,而不是整个模型。