2013-08-28 52 views
4

我使用ExtJS 4.2并创建了一个分拣机商店。商店从JSONP Web服务调用加载数据就好了,但拒绝排序。以下是我的模型,商店和负载调用的表示。ExtJS数据存储没有排序

型号:

Ext.define('Desktop.models.products.DtoProductFamilyModel', { 
extend: 'Ext.data.Model', 
fields: [ 
    { 
     name: 'ProductFamilyId', 
     type: 'string', 
     useNull: false, 
     defaultValue: Util.getBlankGuid() 
    }, 
    { 
     name: 'ParentProductFamilyId', 
     type: 'string', 
     useNull: true, 
     defaultValue: Util.getBlankGuid() 
    }, 
    { 
     name: 'BaseItemId', 
     type: 'string', 
     useNull: true, 
     defaultValue: Util.getBlankGuid() 
    }, 
    { 
     name: 'Name', 
     type: 'string', 
     useNull: false, 
     defaultValue: '' 
    }, 
    { 
     name: 'DisplayName', 
     type: 'string', 
     useNull: false, 
     defaultValue: '' 
    }, 
    { 
     name: 'ExternalReferenceId', 
     type: 'string', 
     useNull: true, 
     defaultValue: null 
    } 
] 
}); 

商店:利用

Ext.define('Desktop.stores.products.GetProductFamiliesStore', { 
extend: Ext.data.Store, 
model: 'Desktop.models.products.DtoProductFamilyModel', 
proxy: { 
    type: 'jsonp', 
    url: 'http://www.somejsonpwebservice.com', 
    method: 'GET', 
    pageParam: false, 
    startParam: false, 
    limitParam: false, 
    timeout: 9000000, 
    noCache: true, 
    headers: { 'Content-Type': 'application/json;charset=utf-8' }, 
    sorters: [{ 
     property: 'Name', 
     direction: 'ASC' 
    }], 
    sortRoot: 'Name', 
    sortOnLoad: true, 
    remoteSort: false, 
    reader: { 
     type: 'json' 
    } 
} 
}); 

ComboBox组件商店:

{ 
     xtype: 'combo', 
     zzid: 'cmbProductManufacturersFamily', 
     store: 'Desktop.stores.products.GetProductFamiliesStore', 
     width: 250, 
     labelWidth: 50, 
     forceSelection: true, 
     fieldLabel: Util.translate('Family'), 
     emptyText: 'Select Product Family', 
     margin: '0 0 0 10', 
     displayField: 'Name', 
     valueField: 'ProductFamilyId' 
    } 

实际调用加载店:

this.stoProductFamilies = this.cmbProductManufacturersFamily.getStore(); 
this.stoProductFamilies.load() 

数据加载得很好,但商店拒绝对我的数据进行排序。我将超过100条动态记录加载到组合框中,并且需要使用此功能。如果任何人都可以提供有关我在做什么错误的见解,我将不胜感激。

回答

18

sortOnLoad,remoteSort和配置不设置代理,而不是他们在商店这样设置分拣机:

Ext.define('Desktop.stores.products.GetProductFamiliesStore', { 
    extend: Ext.data.Store, 
    model: 'Desktop.models.products.DtoProductFamilyModel', 
    sorters: [{ 
     property: 'Name', 
     direction: 'ASC' 
    }], 
    sortRoot: 'Name', 
    sortOnLoad: true, 
    remoteSort: false, 
    proxy: { 
     type: 'jsonp', 
     url: 'http://www.somejsonpwebservice.com', 
     method: 'GET', 
     pageParam: false, 
     startParam: false, 
     limitParam: false, 
     timeout: 9000000, 
     noCache: true, 
     headers: { 'Content-Type': 'application/json;charset=utf-8' }, 
     reader: { 
      type: 'json' 
     } 
    } 
});