PDA

View Full Version : Add extra parameters to store filter



incutonez
6 Jun 2014, 12:08 PM
I have a store that gets filtered remotely. I'm creating x amount of Filter config objects and pushing them onto the store. What I need is for each Filter object to have a certain parameter that gets sent back to the server with the filter object, but unfortunately, it looks like what gets sent back to the server is locked down. This is an outline of what the Filter config object looks like:



var filters = [{
property: 'service_name',
value: ['123', '346'],
inverted: true
}, {
property: 'service_id',
value: [1, 5, 7]
inverted: false
}];
store.addFilter(filterConfig);


After store.addFilter fires, what gets sent is


"filter": [
{"property": "service_name", "value": ["123", "346"]},
{"property": "service_id", "value": [1, 5, 7]}
]


What I need is that inverted property to be sent as well. I could use extraParams on the store, but then I'd have to devise some sort of system for matching it with the filter data, which I don't want to do. The other idea is overriding wherever these values get packaged up and sent to the server... I'm imagining that happens somewhere in the proxy or store? I know the filterchange event fires, but have yet to track down where it gets listened.

I'm curious to know if anyone has any ideas on how to solve this? Any help would be appreciated.

scottmartin
6 Jun 2014, 2:50 PM
You could override the encodeFilters function in the store proxy to include the extra param in the filter.

incutonez
7 Jun 2014, 7:56 AM
Yup, just hunted that down right before I left work. Thanks.