简体   繁体   English

在extjs中选择其他网格行时不存储单元格值

[英]Not storing cell value when other grid row is selected in extjs

I'm having two grid in application & I'm using rowSelectionModel. 我在应用程序中有两个网格,我正在使用rowSelectionModel。 Now after user write anything in editable cell & then (w/o clicking anywhere) clicks on main grid row; 现在,在用户在可编辑单元格中写入任何内容之后,然后(不单击任何位置)单击主网格行; rowselect function is getting called. rowselect函数被调用。

Please tell me way to retain the data in cell ??? 请告诉我将数据保留在单元格中的方法吗?

/*********main tree *************/
var gridtree = new Ext.ux.maximgb.tg.EditorGridPanel({
            id: 'mainTree',
            store: storeCMP,
            autoScroll: true,
            layout: 'fit',
            cm: colModeltree,
            title: 'Text Execution Form',
            master_column_id: 'NAME',
            width: screen.width - 120,
            height: 170,
            columnWidth: 0.1,
            sm: new Ext.grid.RowSelectionModel({
                singleSelect: true,
                autoExpandColumn: 'NAME',
                listeners: {
                    rowselect: function(sm, row, rec) {
                        renderFloatingArray(); 
                        var sgrid = Ext.getCmp("mainTree");
                        if (rec.data.level === 0) {
                            titlegrid = rec.data.NAME;
                            Ext.getCmp("questionGrid").hide();
                            Ext.getCmp("sampleGrid").hide();
                        } else if (rec.data.level === 1) {
                            titlegrid = rec.data.NAME;
                            Ext.getCmp('sampleGrid').setTitle('Samples for   ' + titlegrid + ' ');
                            if (F.TRO_GRC_OBJECT_TYPE.read(1) === "") {
                                filterdataQs(gridStoreQs, rec.data.TST_TEST_EXECUTION_ID, rec.data.TESTING_ID);
                                if (Ext.getCmp('questionGrid').getStore().data.items.length === 0) {
                                    Ext.getCmp("questionGrid").hide();
                                } else {
                                    Ext.getCmp('questionGrid').setTitle(' Questions for ' + titlegrid + ' ');
                                    Ext.getCmp("questionGrid").show();
                                }
                                Ext.getCmp('sampleGrid').setTitle('Samples for ' + titlegrid + ' ');
                                Ext.getCmp("sampleGrid").show();
                                filterdataQs(gridStoreQs, rec.data.TST_TEST_EXECUTION_ID, rec.data.TESTING_ID);
                                filterdatasample(sampleGridstore, rec.data.TST_TEST_EXECUTION_ID, rec.data.TESTING_ID);
                            } else {
                                Ext.getCmp("questionGrid").hide();
                                Ext.getCmp("sampleGrid").hide();
                            }
                        } else if (rec.data.level == 2) {
                            Ext.getCmp("questionGrid").show();
                            Ext.getCmp("sampleGrid").show();
                            filterdataQs(gridStoreQs, rec.data.TST_TEST_EXECUTION_ID, rec.data.TRID_OBJID_ORG_ID);
                            filterdatasample(sampleGridstore, rec.data.TST_TEST_EXECUTION_ID, rec.data.TRID_OBJID_ORG_ID);
                        }}}}),
            listeners: {
                viewready: function(g) {
             if (F.TRO_GRC_OBJECT_TYPE.read(1) === "") {
                        g.getSelectionModel().selectRow(1);
                    } else {
                        g.getSelectionModel().selectRow(2);
                    }
                },

                'rowcontextmenu': gridContextMenu


            },

            viewConfig: {
                enableRowBody: true


            },

            plugins: [{
                ptype: 'editable-grid'
            }]

        });

question - grid 问题-网格

var grid2 = new Ext.grid.EditorGridPanel({
            id: 'questionGrid', 
            store: gridStoreQs,
            hidden: false,
            layout: 'fit',
            autoScroll: true,
            sm: new Ext.grid.RowSelectionModel({
                singleSelect: true,
                listeners: {
                    rowselect: function(sm, row, rec) {
                        currentgrid = 'questionGrid';}}}),
            width: screen.width - 120,
            autoHeight: true,
            columnLines: true,
            viewConfig: {
            },
            title: 'Question Grid',
            cm: colModelQs,
            enableKeyEvents: true,
            plugins: [{ ptype: 'editable-grid' }],
            onEditComplete: function(ed, value, startValue) {
            if (ed.field.getXType() == "numberfield" || ed.field.getXType() == "textfield") {
                    this.editing = false;
                    this.activeEditor = null;
                    ed.un("specialkey", this.selModel.onEditorKey, this.selModel);
                    var r = ed.record;
                    var field = this.colModel.getDataIndex(ed.col);
                    var e = {
                        grid: this,
                        record: r,
                        field: field,
                        originalValue: startValue,
                        value: value,
                        row: ed.row,
                        column: ed.col,
                        cancel: false
                    };
                    if (this.fireEvent("validateedit", e) !== false && !e.cancel) {
                        r.set(field, value);
                        delete e.cancel;
                        this.fireEvent("afteredit", e);
                    }

                    this.view.focusCell(ed.row, ed.col);
                }
            },
            listeners: {
                'afteredit': afterTreeGridCellEdit
            }
        });

plugin used : editable-grid 使用的插件:editable-grid

The value is saved into the underlying record on cell editor blur event. 该值将保存到单元格编辑器模糊事件的基础记录中。 Only if the entered value is invalid it is reverted back. 仅当输入的值无效时,它才被还原。 So check if you are entering a valid value and if it does not help prepare a showcase on https://fiddle.sencha.com 因此,请检查您是否输入了有效值,并且它是否无助于在https://fiddle.sencha.com上准备展示柜

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM