如何在ext窗口中设置网格行getSelectionModel数据

时间:2017-03-20 07:47:00

标签: extjs

我不是要在ext窗口中设置行选数据,你能不能给出解决方案。我的代码在这里..

var shiftWindow = Ext.create('Ext.window.Window', {
    title: 'Edit Shift',
    resizable: false,
    id: 'shiftwindow',
    width: 465,
    //bodyPadding: 5,
    modal: true,
    store: shiftStorePlanner,

    items: {
        xtype: 'form',
        id: 'idFormShift',
        bodyPadding: 10,
        items: shiftViewModelPlannerData
    },
    buttons: [{
        text: 'Save',
        cls: 'planner-save-button',
        overCls: 'planner-save-button-over',
        handler: function() {
            var wi = this.up('.window')
            var form = Ext.getCmp('idFormShift');
            if (form.isValid()) {
                shiftTimemappingarray = [];
                getShiftTime();
                //this.up('.window').close();
            }
        }
    }, {
        text: 'Cancel',
        handler: function() {
            this.up('.window').close();
        }
    }]
});

    var host1 = Ext.getCmp('plannershifteditor');
    var selection = host1._shiftPlannerGrid.getSelectionModel().getSelection();
    if (selection.length === 0) {

        return;
    }

    Ext.getCmp('shiftWindow').getForm().setValues(selection[0].data);
    shiftWindow.show();
     }

1 个答案:

答案 0 :(得分:1)

取决于您的ExtJS版本:

var selection = grid.getSelectionModel().getSelection();
grid.getForm().loadRecord(selection[0]);

稍后您可以使用updateRecord()使用表单值更新模型。

更多信息:

ExtJS 5及更高版本也支持viewmodel绑定。这将自动完成工作。

相关问题