表单和网格 Extjs 之间的绑定

BINDING between Form and Grid Extjs

所以我想要实现的是用选定的行记录填充表单 and/or 通过表单编辑行,通过 ViewModel 所以它是双向绑定,我已经完成了状态字段,但我在其他字段上遇到问题,我尝试了公式,但也没有用。 这是一个处理记录的处理程序,但我无法将它们与表单字段绑定。

   store = this.getView().getStore();
         var records = record.getSelected().items[0].data;
                //var record = records[0];
                 console.log('showChart',records)
                if (records) {
                    this.getView().getDialog().loadRecord(records);
                }
       console.log(records.name);

这是我的Fiddle example

您需要将选定的记录传输到表单,并设置表单字段的绑定(bind: {value: ''}) 属性。 一种简单的方法是将选定的网格记录传递给 Test.main.Form 的 viewModel。看:

mainController.js:

...
showChart: function (record, selModel) {

    var form = Ext.create({
        xtype: 'testform'
    });

    //selModel is actually an array of selected records.
    form.getViewModel().set('record', selModel[0]);

    form.show();

},
...

form.js:

...
items: [{
    label: 'First Name',
    name: 'first',
    bind: {
        //record that was set in the showChart function.
        value: '{record.name}'
    }
...

尝试使用其他字段。

希望对您有所帮助。任何问题,让我知道。