Javascript Extjs组合diplay值-如果未找到值
我正在使用这种技术来实现组合框的自动完成功能,它返回汽车的名称和类型,有时类型未知,因此不会返回任何内容,我希望它是“无数据”,因此我使用了这个Javascript Extjs组合diplay值-如果未找到值,javascript,extjs,autocomplete,Javascript,Extjs,Autocomplete,我正在使用这种技术来实现组合框的自动完成功能,它返回汽车的名称和类型,有时类型未知,因此不会返回任何内容,我希望它是“无数据”,因此我使用了这个valueNotFoundText:'无数据',但不起作用 xtype: 'combo', store: s, hideTrigger:true, typeAhead: false, id: 'search', queryMode: 'remote', queryParam: 'query', displayField: 'name',//+'type'
valueNotFoundText:'无数据'
,但不起作用
xtype: 'combo',
store: s,
hideTrigger:true,
typeAhead: false,
id: 'search',
queryMode: 'remote',
queryParam: 'query',
displayField: 'name',//+'type',
valueField: 'name',//+'type',
//valueNotFoundText: 'No Data',
,listConfig: {
loadingText: ' Loading...',
getInnerTpl: function() {
return '{name}'+'<br>'+'<p><font size="1">{type}'+':type</font></p>';
}
,
}
, listeners: {
xtype:'combo',
商店:s,
希德崔格:没错,
typeAhead:false,
id:'搜索',
queryMode:'远程',
queryParam:“查询”,
displayField:'名称',//+'类型',
valueField:'名称',//+'类型',
//valueNotFoundText:“无数据”,
,listConfig:{
loadingText:“正在加载…”,
getInnerTpl:函数(){
返回'{name}'+'
'+'{type}'+':type';
}
,
}
,听众:{
您可以在列表配置中使用上的emptyText配置选项。组合框内部列表类BoundList从视图扩展,因此它遵循相同的api
我猜您正在寻找这种类型(简化的工作示例)
谢谢,但是当没有任何结果出现时,这将显示消息。但是在我的例子中,名称总是返回,但类型不返回。因此结果将是:
name:mike type:
。因此,当类型为null时,我需要它是“无数据”。
listConfig: {
emptyText: 'No Data'
}
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
typeAhead: true, // this will simply show the typed text if nothing is found.
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
tpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<div class="x-boundlist-item">{abbr}</div>',
'</tpl>'
),
displayTpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<tpl if="name.length == 0"> ',
'no data', // You can return any other additional value or formating here
'<tpl else>',
'{name}', // You can return any other additional value or formating here
'</tpl>',
'</tpl>'
),
valueNotFoundText: 'no data' // this will be displayed if no record is found after setValue()
});
var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name','ctype'],
data : [
{"abbr":"AL", "name":"Alabama", "ctype":"AL"},
{"abbr":"AK", "name":"Alaska", "ctype":"AK"},
{"abbr":"AZ", "name":"Arizona", "ctype":""}
]
});
// Create the combo box, attached to the states data store
Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
typeAhead: true, // this will simply show the typed text if nothing is found.
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
tpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<tpl if="ctype.length == 0"> ',
'<div class="x-boundlist-item">{name}<p><font size="1">no data</font></p></div>',
'<tpl else>',
'<div class="x-boundlist-item">{name}{ctype}<p><font size="1">{ctype}</font></p></div>',
'</tpl>',
'</tpl>'
),
displayTpl: Ext.create('Ext.XTemplate',
'<tpl for=".">',
'<tpl if="itype.length == 0"> ',
'no data',
'<tpl else>',
'{name}',
'</tpl>',
'</tpl>'
),
valueNotFoundText: 'no data', // this will be displayed if no record is found after setValue()
renderTo: Ext.getBody()
});