我在商店中有一个JSON对象,如下所示。我根据属性网格中的选择动态过滤值。我没有过滤顶级值(personName,primaryRole等),而是想深入查看我所拥有的句点数组。例如,我想过滤商店中的每个记录"句点" > " periodName&#34 ;.
我不知道该怎么做,因为它不是我之前遇到过的。使用combo.getStore().filter('periodName', gridvalues.periodName);
不起作用,因为它找不到periodName,我不能简单地使用periods.periodName。
"id": "531b0633-c9f5-4cbe-be69-5df4944b6e9b",
"personName": "Ben",
"primaryRole": "SWE",
"secondaryRole": "SWE",
"periods": [
{
"personName": "Ben",
"periodName": "Week 24",
"teamName": "Tango",
"experience": 2,
"periodNumber": 24,
"id": "71d514c2-a39f-40b7-af9e-51fbf30b2a48"
},
{
"personName": "Ben",
"periodName": "Week 25",
"teamName": "-",
"experience": "-",
"periodNumber": 25,
"id": "49505fb2-97df-4f45-a11d-bb22c110a422"
},
{
"personName": "Ben",
"periodName": "Week 26",
"teamName": "-",
"experience": "-",
"periodNumber": 26,
"id": "97f2b272-c23c-4320-a1ce-09dadf0c6b5d"
},
"id": "7037ad16-dcbe-4326-8547-65108c03c874",
"personName": "Luke",
"primaryRole": "Product Owner",
"secondaryRole": "SWE",
"periods": [
{
"personName": "Luke",
"periodName": "Week 24",
"teamName": "Tango",
"experience": 3,
"periodNumber": 24,
"id": "e3184bef-c330-4219-ae21-8b65efcde77c"
},
{
"personName": "Luke",
"periodName": "Week 25",
"teamName": "-",
"experience": "-",
"periodNumber": 25,
"id": "f431af7b-8060-40d2-8464-af533d943363"
},
这是我商店的记录:
id: "531b0633-c9f5-4cbe-be69-5df4944b6e9b"periodNumber: 0periods: Array[16]0: Objectexperience: 2id: "71d514c2-a39f-40b7-af9e-51fbf30b2a48"periodName: "Week 24"periodNumber: 24personName: "Ben"teamName: "Tango"__proto__: Object1: Object2: Object3: Object4: Object5: Object6: Object7: Object8: Object9: Object10: Object11: Object12: Object13: Object14: Object15: Objectlength: 16__proto__: Array[0]personName: "Ben"primaryRole: "SWE"secondaryRole: "SWE"
答案 0 :(得分:1)
使用控制器中的addFilter
功能:
combo.getStore().addFilter({property: 'yourProperty', value: 'valueToFilter'});
欲了解更多信息:
http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.data.Store-method-addFilter