日期:2014-05-16  浏览次数:20831 次

Ext4.1 RowEditing中combo值为[object Object]
JScript code

Ext.onReady(function(){    
        var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
            clicksToMoveEditor: 1,
            autoCancel: false
        });
        
        Ext.create('Ext.data.Store', {
            storeId:'findEvertsStore',
            fields: ['id', 'calendar','title', 'start','end', 'loc','notes', 'url','ad', 'rem', 'n'],
            proxy: {
                type: 'ajax',
                url: 'findEverts.action',
                reader: {
                    type: 'json',
                    root: 'everts'
                }
            },
            autoLoad: true
        });
        
        var states = Ext.create('Ext.data.Store', {
            fields:['id','title'],
            proxy: {
                type: 'ajax',
                url: 'findCalendars.action',
                reader: {
                    type: 'json',
                    root: 'calendars'
                }
            },
            autoLoad: true
        });
        
        var grid = Ext.create('Ext.grid.Panel', {
            title: 'Simpsons',
            store: Ext.data.StoreManager.lookup('findEvertsStore'),
            columns: [
                { header: 'id',  dataIndex: 'id' },
                { 
                    header: 'calendar', 
                    dataIndex: 'calendar',
                    renderer: function(value){
                        if(value != null){
                            return value.title;
                        }
                    },
                    flex: 1,
                    editor: {
                        xtype: 'combo',
                        id: 'mt',
                        store: states,
                        displayField: 'title',
                        valueField: 'id',
                        allowBlank: false
                    }
                },
                { header: 'title', dataIndex: 'title' }
            ],
            height: 200,
            width: 800,
            tbar: [{
                text: 'Add Employee',
                iconCls: 'employee-add',
                handler : function() {
                    rowEditing.cancelEdit();
    
                    // Create a model instance
                    var r = Ext.create('Employee', {
                        name: 'New Guy',
                        email: 'new@sencha-test.com',
                        start: new Date(),
                        salary: 50000,
                        active: true
                    });
    
                    store.insert(0, r);
                    rowEditing.startEdit(0, 0);
                }
            }, {
                itemId: 'removeEmployee',
                text: 'Remove Employee',
                iconCls: 'employee-remove',
                handler: function() {
                    /**
                    var sm = grid.getSelectionModel();
                    rowEditing.cancelEdit();
                    store.remove(sm.getSelection());
                    if (store.getCount() > 0) {
                        sm.select(0);
                    }
                    */
                },
                disabled: true
            }],
            plugins: [rowEditing],
            listeners: {
                'selectionchange': function(view, records) {
                    grid.down('#removeEmployee').setDisabled(!records.length);
                }
            },
            renderTo: Ext.getBody()
        });
        
      });



为什么在点击修改时,combo里面显示的[object Object]
combo原值是一个对象,grid显示正常,修改时显示不正常.
求各位帮忙解答一下.谢谢!

------解决方案--------------------
首先确认的是你findCalendars.action的返回值是什么,再者是你在点击那行的combo是否有值,最后是要说出你点下拉的时候是什么情况,说出如上情况,才能帮你分析