extjs4改动很大,bug也很多!
一直在踩雷的过程中……
本人目前版本为4.0.2a
问题:
下拉框的分页不能正确翻页,如下为出问题的代码:
{
name: 'submitterId',
fieldLabel: '提交人',
xtype: 'combo',
triggerAction: 'all',
queryMode: 'remote',
hiddenName : 'id',
minChars : 1,
queryParam: 'nickname',
store: submitterStore = Ext.create('Ext.data.Store', {
proxy: {
type: 'ajax',
url: 'saler/getQuerySalers.json',
method: 'POST',
reader: {
type: 'json',
totalProperty : 'page.totalCount',
root: 'page.result'
}
},
pageSize : 2,
fields :[{
name : 'id'
}, {
name : 'nickname'
}]
}),
valueField: 'id',
displayField: 'nickname',
listConfig : {
minWidth: 280
},
pageSize : 2
}
去国外论坛也没有找到好的解决方案,于是只能自己看源码找到问题所在,贴上解决代码,希望对大家有所帮助:
Ext.apply(Ext.form.field.ComboBox.prototype, {
doQuery: function(queryString, forceAll) {
queryString = queryString || '';
var me = this,
qe = {
query: queryString,
forceAll: forceAll,
combo: me,
cancel: false
},
store = me.store,
isLocalMode = me.queryMode === 'local';
if (me.fireEvent('beforequery', qe) === false || qe.cancel) {
return false;
}
queryString = qe.query;
forceAll = qe.forceAll;
if (forceAll || (queryString.length >= me.minChars)) {
me.expand();
if (!me.queryCaching || me.lastQuery !== queryString) {
me.lastQuery = queryString;
if (isLocalMode) {
if (forceAll) {
store.clearFilter();
} else {
store.clearFilter(true);
store.filter(me.displayField, queryString);
}
} else {
Ext.apply(store.getProxy().extraParams, me.getParams(queryString));
store.load();
}
}
if (me.getRawValue() !== me.getDisplayValue()) {
me.ignoreSelection++;
me.picker.getSelectionModel().deselectAll();
me.ignoreSelection--;
}
if (isLocalMode) {
me.doAutoSelect();
}
if (me.typeAhead) {
me.doTypeAhead();
}
}
return true;
}
});