Extjs 4 remote filter store smaller (<) bigger (>) than

非 Y 不嫁゛ 提交于 2019-12-13 19:40:26

问题


Is it possible to remote filter smaller than and bigger than? I know how to handle this in php and mysql but I don't know how to set such a filter in a extjs 4 store.


回答1:


Out of the box with 4.1, no.

You will need to overwrite the responsible provider proxy for that cause currently only property-value pairs get submitted (responsible function). The other point is that the Ext.util.Filter don't support any comparator for remotesort at all. So you have to implement your own and ensure that the store don't support local filtering (cause that won't work).

As a workarround you can commit the smaller/bigger along with the value as encoded string and substract the it then on the serverside. This would just cause a local filter to get no results.




回答2:


I usually override the Ext.data.proxy.Server, like this:

// ext store remote filter missing operator fix
Ext.override(Ext.data.proxy.Server, {encodeFilters: function(filters) {
    var min = [],
        length = filters.length,
        i = 0;

    for (; i < length; i++) {
        if(filters[i].property && filters[i].value){
            min[i] = {
                operator: filters[i].operator,
                property: filters[i].property,
                value   : filters[i].value
            };
        }
    }
    return this.applyEncoding(min);
}});


来源:https://stackoverflow.com/questions/12216588/extjs-4-remote-filter-store-smaller-bigger-than

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!