Extjs combobox typeahead ctrl + v 错误
Ext js combo box typehead crtl + v error
我有组合框并输入 head true。在更改事件中,我正在发出 ajax 请求以获取匹配结果。
如果在那里输入那么它工作正常,但是如果我在组合中复制粘贴然后它显示结果但给出错误并阻止进一步的流程。
下面是代码。
{
xtype : 'combo',
emptyText : 'Search',
id : 'search',
store : Store,
width : '50%',
minChars : 3,
typeAhead : true,
anchor : '100%',
listConfig : {
emptyText : 'No Matching results found.',
getInnerTpl: function() {
return '<div class="search">' +
'<span>{value} - {key}</span>'+
'</div>';
}
},
listeners : {
beforequery: function (record) {
// Added Condition to avoid weird JS error
if(Ext.getCmp('search').getValue() != null && Ext.getCmp('search').getValue().length <= 4){
return false;
}
},
select : function(combo, selection){
var selectedVal = selection[0].data.value;
Ext.getCmp('search').setValue( selectedVal );
},
change : function () {
if( Ext.getCmp('search').getValue() != null && Ext.getCmp('search').getValue().length > 4 ){
var searchEle = Ext.getCmp('search');
var searchType = Ext.getCmp('searchBy').getValue();
var searchText = '%';
searchText += searchEle.getValue();
Ext.Ajax.request({
loadMask : true,
url : URL,
method : 'GET',
params : {
searchText : searchText,
searchType : searchType,
},
scope : this,
success : function( response, callOptions ) {
var myTempData = Ext.decode( response.responseText );
Store.setProxy({
type : 'memory',
data : myTempData,
reader : {
type : 'json',
root : 'data',
totalProperty : 'total',
successProperty : 'success'
}
});
Store.load({
scope : this,
callback : function(records, operation, success) {
}
});
},
failure : function(response, options ) {
loadmask.hide();
Ext.Msg.alert( 'Error', genericErrorMsg );
}
});
}
}
}
报错如下
非常感谢您的帮助。谢谢
Json 回应
{"value":"Test , user @ IB Tech: Strategic Change","key":"45804183"},
终于解决了
商店出现问题。
我在 ajax 成功后绑定它并从初始配置中删除它并解决了它。
Store.load({
scope : this,
callback : function(records, operation, success) { }
});
Ext.getCmp('search').bindStore(Store);
我有组合框并输入 head true。在更改事件中,我正在发出 ajax 请求以获取匹配结果。
如果在那里输入那么它工作正常,但是如果我在组合中复制粘贴然后它显示结果但给出错误并阻止进一步的流程。
下面是代码。
{
xtype : 'combo',
emptyText : 'Search',
id : 'search',
store : Store,
width : '50%',
minChars : 3,
typeAhead : true,
anchor : '100%',
listConfig : {
emptyText : 'No Matching results found.',
getInnerTpl: function() {
return '<div class="search">' +
'<span>{value} - {key}</span>'+
'</div>';
}
},
listeners : {
beforequery: function (record) {
// Added Condition to avoid weird JS error
if(Ext.getCmp('search').getValue() != null && Ext.getCmp('search').getValue().length <= 4){
return false;
}
},
select : function(combo, selection){
var selectedVal = selection[0].data.value;
Ext.getCmp('search').setValue( selectedVal );
},
change : function () {
if( Ext.getCmp('search').getValue() != null && Ext.getCmp('search').getValue().length > 4 ){
var searchEle = Ext.getCmp('search');
var searchType = Ext.getCmp('searchBy').getValue();
var searchText = '%';
searchText += searchEle.getValue();
Ext.Ajax.request({
loadMask : true,
url : URL,
method : 'GET',
params : {
searchText : searchText,
searchType : searchType,
},
scope : this,
success : function( response, callOptions ) {
var myTempData = Ext.decode( response.responseText );
Store.setProxy({
type : 'memory',
data : myTempData,
reader : {
type : 'json',
root : 'data',
totalProperty : 'total',
successProperty : 'success'
}
});
Store.load({
scope : this,
callback : function(records, operation, success) {
}
});
},
failure : function(response, options ) {
loadmask.hide();
Ext.Msg.alert( 'Error', genericErrorMsg );
}
});
}
}
}
报错如下
非常感谢您的帮助。谢谢
Json 回应
{"value":"Test , user @ IB Tech: Strategic Change","key":"45804183"},
终于解决了
商店出现问题。
我在 ajax 成功后绑定它并从初始配置中删除它并解决了它。
Store.load({
scope : this,
callback : function(records, operation, success) { }
});
Ext.getCmp('search').bindStore(Store);