2016-09-30 97 views
0

我想用我的网格与组合框排序,我希望当我选择组合框上的值时,网格的内容改变,例如type任何人都可以帮助我吗?感谢Extjs 6 - 与组合框过滤网格

这个我的代码片段:

Ext.create('Ext.grid.Panel', { 
    height: 400, 
    title: 'Simpsons', 
    store: pagingStore, 
    columns: [{ 
      text: 'Name', 
      dataIndex: 'name' 
     }, { 
      text: 'Email', 
      dataIndex: 'email' 
     }, { 
      text: 'Phone', 
      dataIndex: 'phone' 
     }, 
     { 
      text: 'Type', 
      dataIndex: 'type' 
     }], 
    bbar: { 
     xtype: 'pagingtoolbar', 
     store: pagingStore, 
     displayInfo: true, 
     items: [ 
      '-', { 
       xtype: 'combo', 
       fieldLabel: 'List account', 
       labelAlign: 'right', 
       store: storeCombo, 
       displayField: 'name' 
      }] 
    }, 
    renderTo: Ext.getBody() 
}); 
+0

您希望您的网格上的类型列上的选择进行排序组合框对吗? – UDID

+0

我想要这样的:> https://drive.google.com/open?id=0B4va_pdrT1cceHB3N2dySDBpTVE – Joy

+0

客户帐户选择后会发生什么。 – UDID

回答

1

你可能想是这样的:

Ext.create('Ext.grid.Panel', { 
    height: 400, 
    title: 'Simpsons', 
    store: { 
     fields: ['name', 'email', 'phone', 'type'], 
     data: [{ 
      name: 'Homer', 
      email: '[email protected]', 
      phone: '111-222-333', 
      type: 'Foo' 
     }, { 
      name: 'Marge', 
      email: '[email protected]', 
      phone: '111-222-334', 
      type: 'Foo' 
     }, { 
      name: 'Bart', 
      email: '[email protected]', 
      phone: '111-222-335', 
      type: 'Bar' 
     }, { 
      name: 'Lisa', 
      email: '[email protected]', 
      phone: '111-222-336', 
      type: 'Bar' 
     }] 
    }, 
    columns: [{ 
     text: 'Name', 
     dataIndex: 'name' 
    }, { 
     text: 'Email', 
     dataIndex: 'email' 
    }, { 
     text: 'Phone', 
     dataIndex: 'phone' 
    }, { 
     text: 'Type', 
     dataIndex: 'type' 
    }], 
    bbar: { 
     xtype: 'toolbar', 
     items: [ 
      '-', { 
       xtype: 'combo', 
       fieldLabel: 'List account', 
       labelAlign: 'right', 
       forceSelection: true, 
       emptyText: '-- Select --', 
       store: { 
        fields: ['type'], 
        data: [{ 
         type: 'Foo' 
        }, { 
         type: 'Bar' 
        }] 
       }, 
       displayField: 'type', 
       valueField: 'type', 
       listeners: { 
        change: function(combo, value) { 
         var grid = this.up('grid'), 
          store = grid.getStore(); 

         if (!value) { 
          store.getFilters().removeAll(); 
         } else { 
          store.filter([{ 
           property: 'type', 
           value: value 
          }]); 
         } 
        } 
       } 
      } 
     ] 
    }, 
    renderTo: Ext.getBody() 
}); 

https://fiddle.sencha.com/#fiddle/1hn4

+0

谢谢,它给了我一个想法:) – Joy