我有一个模型和一家商店工作很好。我可以从数据来源得到记录很好。我的问题在于不能正确地过滤商店。
模型
Ext.define('CostClass', {
extend: 'Ext.data.Model',
idProperty: 'CostClassID',
fields: [{ name: 'CostClassID', mapping: 'WBSCostClassID', type: 'int' },
{ name: 'Class', mapping: 'Class', type: 'string' },
{ name: 'WBSCostSetID', mapping: 'WBSCostSetID', type: 'int' },
{ name: 'CostClassID', mapping: 'WBSCostClassID', type: 'int' },
{ name: 'UseForCAC', type: 'boolean'}]
});商店
var valueStore = Ext.create('Ext.data.Store', {
//autoLoad: true,
autoSync: true,
model: 'CostClass',
remoteFilter: true,
sorters: { property: 'Class', direction: 'ASC' },
proxy: {
type: 'odata',
url: siteUrl + "_vti_bin/PerformancePortalData.svc/WBSCostClasses",
noCache: false,
sortParam: undefined,
limitParam: undefined,
startParam: undefined,
pageParam: undefined,
headers: {
'Accept': 'application/json'
},
reader: {
type: 'json',
root: 'd'
}
}
});滤波器码
valueStore.filter([{ property: 'WBSCostSetID', value: 2, exactMatch: true}]);这将生成一个类似于_vti_bin/PerformancePortalData.svc/WBSCostClasses?$filter=WBSCostSetID eq '2'的Odata调用,但该URI会产生以下错误:
Operator 'eq' incompatible with operand types 'System.Int32' and 'System.String' at position 13.显然,我需要这个调用看起来像$filter=WBSCostSetID eq 2,但是如何更改过滤器代码来执行
发布于 2013-11-15 18:57:11
在看了Sencha文件之后,我仍然不知所措。然而,另一个所以贴给了我答案的线索。
显然(尽管在文档中没有),存在一个type参数,因此我的筛选器代码只需更改为以下内容(注意添加的类型:'int'):
valueStore.filter([{ property: 'WBSCostSetID', value: 2, type: 'int', exactMatch: true}]);https://stackoverflow.com/questions/20008362
复制相似问题