Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.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
ExtJS 4.2网格表单绑定(表单编辑上的更新记录)_Extjs_Extjs4_Extjs4.1 - Fatal编程技术网

ExtJS 4.2网格表单绑定(表单编辑上的更新记录)

ExtJS 4.2网格表单绑定(表单编辑上的更新记录),extjs,extjs4,extjs4.1,Extjs,Extjs4,Extjs4.1,我有一个网格,在选择时将记录绑定到表单 gridSelectionChange: function (model, records) { if (records[0]) { this.getFormdata().getForm().loadRecord(records[0]); } }, 一切正常,但如果我更改任何字段值,网格不会更新记录和数据存储 我读到我必须打电话: form.updateRecord(); 但是,我如何才

我有一个网格,在选择时将记录绑定到表单

gridSelectionChange: function (model, records) {

        if (records[0]) {
            this.getFormdata().getForm().loadRecord(records[0]);
        }
    },
一切正常,但如果我更改任何字段值,网格不会更新记录和数据存储

我读到我必须打电话:

form.updateRecord();
但是,我如何才能在我的字段(文本字段、组合等)的每一个焦点丢失时调用它呢


有没有办法进行双向绑定?

您可以在Ext JS 4 SDK examples/app/simple/simple.html下看到一个工作示例 它将网格绑定到窗口内的窗体

这是实现这一技巧的代码:

    editUser: function(grid, record) {  // this function fires when dblClick on itemRow
        var edit = Ext.create('AM.view.user.Edit').show();   //creates a window a shows it

        edit.down('form').loadRecord(record);  //reference the form and load the record
    },

updateUser: function(button) {         //this function fires on save button of the form
    var win    = button.up('window'),  //get a reference to the window 
        form   = win.down('form'),     // get a reference to the form 
        record = form.getRecord(),     // get the form record
        values = form.getValues();     // get the values of the form

    record.set(values);                //set the values to the record (same object shared with the grid) 
    win.close();                      //close window
    this.getUsersStore().sync();      // this line is only necesary if you want to synchronize with the server
}
  var record = form.getRecord(),     
      values = form.getValues();     
      record.set(values); 
底线do:

    editUser: function(grid, record) {  // this function fires when dblClick on itemRow
        var edit = Ext.create('AM.view.user.Edit').show();   //creates a window a shows it

        edit.down('form').loadRecord(record);  //reference the form and load the record
    },

updateUser: function(button) {         //this function fires on save button of the form
    var win    = button.up('window'),  //get a reference to the window 
        form   = win.down('form'),     // get a reference to the form 
        record = form.getRecord(),     // get the form record
        values = form.getValues();     // get the values of the form

    record.set(values);                //set the values to the record (same object shared with the grid) 
    win.close();                      //close window
    this.getUsersStore().sync();      // this line is only necesary if you want to synchronize with the server
}
  var record = form.getRecord(),     
      values = form.getValues();     
      record.set(values); 

这样可以一次保存一条记录。但是我想从表单字段更新我的网格,并在最后将所有修改的记录同步到服务器。有什么线索吗?只要删除这个.getUsersStore().sync();若要让记录在网格中保持不干净,请在用户上单击“更新”按钮(网格工具栏上),然后同步。无法侦听每个字段的“失去焦点”事件,因此在失去焦点后,记录会更新吗?有可能吗???我不明白最后一部分。所以dblClick在网格行上,edit on form,save on form,record modified on grid但未保存在server上,执行n次,然后侦听特定事件并同步网格存储。是的,这是可能的,只要决定哪个事件将触发同步。失去焦点不是我的选择,因为你不知道有多少记录将被修改。。。因此,要么像sencha示例中那样在表单上保存after edition,要么查找另一个事件