2012-04-21 34 views
0

我有使用远程存储和远程分页,因为我有主电网太多records.The店一格是:ExtJS的4基于一个组合框选择呈现新的网格

Ext.define('ArD.store.RecordsListStore', { 

    extend: 'Ext.data.Store', 
    model: 'ArD.model.RecordsListModel', 

    autoLoad: true, 
    autoSync: true, 
    remoteSort: true, 
    remoteFilter: true, 

    pageSize: 15, 


    proxy: { 
     type: 'ajax', 
     actionMethods: 'POST', 
     api: { 
      read: g_settings.baseUrl + 'index.php/recordslist/getAll', 

      destroy: g_settings.baseUrl + 'index.php/recordslist/deleteRecord' 
     }, 
     reader: { 
      type: 'json', 
      root: 'data', 
      totalProperty: 'totalCount', 
      successProperty: 'success' 
     }, 
     writer: { 
      root: 'data', 
      writeAllFields: true, 
      encode: true 
     } 
    } 


}); 

然后我填充我的网格和它都很好。但问题是,我有一个组合框,看起来像这样:

{ 
          xtype: 'combo', 
          id: 'records_list_form_id', 
          emptyText: 'Choose Form', 
          editable: false, 
          store: 'FilterRecordsByForm', 
          displayField: 'title', 
          valueField: 'id', 
          lastQuery: '', 
          triggerAction: 'all', 
          queryMode: 'remote', 
          typeAhead: false, 
          width: 200, 
          listeners: { 
           select: this._filterRecords 
          } 
         } 

当我从下拉框中选择一些有功能:

_filterRecords: function() 
    { 
     var recStore = Ext.getStore('RecordsListStore'); 
     var a = Ext.getCmp('records_list_form_id').getValue(); 
     var rec = Ext.getStore('FilterRecordsByForm').getAt(a); 
     console.log(recStore); 
    }, 

大多只是尝试一些东西,但我可以得到从组合框中选择元素的ID,这就是我所在的位置。

我需要的是让id作为一个新的查询使用我的AJAX api(PHP/SQL后端)并使用与此id相关的信息填充网格。在我的情况下,我有1:M的关系,所以当我通过Id时,我希望在旧网格的位置上呈现M个记录。

感谢

Leron

回答

1

使用filter()方法。提供您需要过滤的信息,存储对象将自动向服务器请求更新的信息(您已经配置了remoteFilter)。

0

看Ext.Ajax的()进行按需Ajax调用服务器端加载了您的数据,然后使用Store.loadData()或类似的东西即重新填充网格。

相关问题