以下是搜索代码
Controller:
onSearchKeyp: function(field) { //get the store and the value of the field var value = field.getValue(), store = Ext.getStore('Customers'); //first clear any current filters on the store. If there is a new value, then suppress the refresh event store.clearFilter(!!value); //check if a value is set first, as if it isnt we dont have to do anything if (value) { //the user could have entered spaces, so we must split them so we can loop through them all var searches = value.split(','), regexps = [], i, regex; //loop them all for (i = 0; i < searches.length; i++) { //if it is nothing, continue if (!searches[i]) continue; regex = searches[i].trim(); regex = regex.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); //if found, create a new regular expression which is case insenstive regexps.push(new RegExp(regex.trim(), 'i')); } //now filter the store by passing a method //the passed method will be called for each record in the store store.filter(function(record) { var matched = []; //loop through each of the regular expressions for (i = 0; i < regexps.length; i++) { var search = regexps[i]; var didMatch = search.test(record.get('customerName')); //if it matched the first or last name, push it into the matches array matched.push(didMatch); } return (regexps.length && matched.indexOf(true) !== -1); }); } },
view:
关键在这里,经过反复查找发现是因为开始没有写 infinite: true,所以会有卡顿现象
id : 'clientList', disableSelection: true, scrollable : 'vertical', xtype : 'list', store : "app0010000002Store", flex : 1, itemTpl : new Ext.XTemplate("<div><span>{customerName}</span></div>"), infinite: true,