我使用ExtJS 4.2并创建了一个带有分类器的商店。存储从JSONP web服务调用加载数据很好,但它拒绝排序。下面是我的模型、存储和加载调用的表示。
型号:
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'
}
}
});
利用商店的组合框组件:
{
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多个动态记录加载到一个组合框中,需要这个功能。如果有人能深入了解我做错了什么,我将不胜感激
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'
}
}
});