1
votes

I'm trying to add new criteria to an Extjs combo autocomplete. When user enters a term in the text field, he should get a suggestions, either a student's name, or a subject. I did successfully accomplish the first case (names only). here is the details: Extjs - Combo with Templates to Display Multiple Values

Now, I should add subject criteria in the autocomplete list, so if user enters Mat, he will get:

Mathio,Jay << student's first and last name

Mark,Matt << student's first and last name

Mathematics << subject

Here is my code, still not working:

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(),
             },
1

1 Answers

2
votes

Seems like the if..else construction inside the template definition is wrong,

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>'),