如何在组合框中显示网格中的数据

时间:2014-02-05 19:35:38

标签: extjs

我的问题是,当我从组合框中选择数据时,如何将数据放入网格

这是我到目前为止所尝试的,

 var store = new Ext.data.JsonStore({
                proxy: new Ext.data.HttpProxy({
                        url: '/index.php/getAnimals'
                    }),
                    root: 'data',
                    pruneModifiedRecords: true,
                    totalProperty: 'total',
                    baseParams: {limit: 25},
                    autoLoad: {params: {start: 0}},
                    fields: ['id','animal_name'],
                    sortInfo: {field:'id', direction:'ASC'}
            });






                var grid = new Ext.grid.EditorGridPanel({
                id: 'editorgrid',
                store: store1,
                title: 'Animals',
                cm: cm1,


                width: 400,
                anchor: '100%',
                height: 700,

                frame: true,
                loadMask: true,
                waitMsg: 'Loading...',
                clicksToEdit: 1,
                tbar: [
                'Animals Unit  : ', '-',               

                {
                xtype: 'combo',
                name: 'company_combo',

                anchor: '90%',
                allowBlank: false,
                editable: false, 
                forceSelection: true,
                triggerAction: 'all',
                mode: 'remote',
                store: new Ext.data.JsonStore({
                    url: '/index.php/getAnimalsCombo',
                    root: 'data',
                    totalProperty: 'total',
                    fields: ['id','desc'],
                    params: {start: 0},
                    baseParams: {limit: 25}
                }),
                pageSize: 25,
                displayField: 'desc',
                valueField: 'id',
                minListWidth: 150,
                valueNotFoundText: '',
                width: 150,
                minChars: 1

                },

                '-',

              ],                
            bbar: pager1
            });

1 个答案:

答案 0 :(得分:1)

您应该为组合设置侦听器...类似这样的

{
                xtype: 'combo',
                name: 'company_combo',
                listeners:{
                    "select":function(theCombo, selectedRecord){
                         var theGrid = theCombo.up("grid");
                         theGrid.reconfigure(newStore, newColModel);
                     }
                },
                anchor: '90%',
                allowBlank: false,
                editable: false, 
                forceSelection: true,
                triggerAction: 'all',
                mode: 'remote',
                store: new Ext.data.JsonStore({
                    url: '/index.php/getAnimalsCombo',
                    root: 'data',
                    totalProperty: 'total',
                    fields: ['id','desc'],
                    params: {start: 0},
                    baseParams: {limit: 25}
                }),
                pageSize: 25,
                displayField: 'desc',
                valueField: 'id',
                minListWidth: 150,
                valueNotFoundText: '',
                width: 150,
                minChars: 1

                },

您可能想查看ExtJS文档,这里是关于网格文档的链接

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.Panel

您还应该在那里寻找组合

相关问题