读书人

Ext ComboBox 能够依据输入的record的

发布时间: 2012-11-23 22:54:33 作者: rapoo

Ext ComboBox 能够根据输入的record的指定字段过滤列表
combo默认能够根据输入的内容过滤的列表内容,不过这个过滤只是根据displayField来的。如果要能够同时根据自己制定的字段过滤就需要如下修改:
在combo的源码的doQuery方法中

if(forceAll === true || (q.length >= this.minChars)){            if(this.lastQuery !== q){                this.lastQuery = q;                if(this.mode == 'local'){                    this.selectedIndex = -1;                    if(forceAll){                        this.store.clearFilter();                    }else{                        this.store.filter(this.displayField, q);                        //hack                        if(this.otherFilterField){                        this.setValue(this.getRawValue());                        if(this.store.data.length==0)                    this.store.filter(                                      this.otherFilterField, q);                    }                    }                                    this.onLoad();



然后需要构造这种combo的时候指定otherFilterField为record的其他字段就可以了

读书人网 >Web前端

热点推荐