我在如下所示的商店中有一个JSON对象。我根据属性网格中的选择动态过滤值。我不是在顶级值(personName,primaryRole等)上进行过滤,而是想深入了解我拥有的句点数组。例如,我想为“ periods”>“ periodName”过滤存储中的每个记录。

我不确定如何执行此操作,因为这不是我以前遇到过的事情。使用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"

最佳答案

在控制器中使用addFilter函数:

combo.getStore().addFilter({property: 'yourProperty', value: 'valueToFilter'});


有关更多信息:

http://docs.sencha.com/extjs/4.2.3/#!/api/Ext.data.Store-method-addFilter

09-16 20:04