Extjs -组合与自动完成:两种类型的值

Extjs - Combo with autocomplete: two types of values

本文关键字:两种 类型 组合 Extjs      更新时间:2023-09-26

我正试图为Extjs组合自动完成添加新标准。当用户在文本字段中输入一个术语时,他应该得到一个建议,要么是学生的名字,要么是主题。我确实成功地完成了第一个案例(只有名字)。Extjs -组合与模板显示多个值

现在,我应该在自动完成列表中添加主题条件,所以如果用户输入Mat,他将得到:

Mathio,周杰伦& lt; & lt;学生的姓和名

马克,马特& lt; & lt;学生的姓和名

数学& lt; & lt;主题

这是我的代码,仍然不能工作:

listConfig: {
        loadingText: 'Loading...',
        tpl: Ext.create('Ext.XTemplate',
        '<tpl for=".">',
        '<tpl if="subject.length != 0"> ',
        '<div class="x-boundlist-item">{subject}</div>',                                       
        '<tpl if="l_name.length == 0"> ',             
       '<div class="x-boundlist-item">{f_name}<p><font size="1">Last Name: Unknown </font></p></div>',
    '<tpl else>',
       '<div class="x-boundlist-item">{f_name}<p><font size="1">{l_name}</font></p></div>',
    </p></div>',
        '</tpl>',
        '</tpl>'),
         renderTo: Ext.getBody(),
             },

似乎模板定义中的if..else结构是错误的,

tpl: Ext.create('Ext.XTemplate',
    '<tpl for=".">',
        '<tpl if="subject.length != 0"> ',
            '<div class="x-boundlist-item">{subject}</div>',
        '<tpl else>',                                       
            '<tpl if="l_name.length == 0"> ',             
                '<div class="x-boundlist-item">{f_name}<p><font size="1">Last Name: Unknown </font></p></div>',
            '<tpl else>',
                '<div class="x-boundlist-item">{f_name}<p><font size="1">{l_name}</font></p></div>',
            '</tpl>',
        '</tpl>',
    '</tpl>'),