2013-05-14 75 views
1

我正在嘗試將新條件添加到Extjs組合自動完成功能中。當用戶在文本字段中輸入一個術語時,他應該得到一個建議,無論是學生的姓名,還是主題。我成功地完成了第一個案例(僅限姓名)。這裏是詳細信息:Extjs - Combo with Templates to Display Multiple ValuesExtjs - 與自動完成功能組合:兩種類型的值

現在,我應該在自動完成列表中添加主題的標準,因此,如果用戶輸入墊,他將獲得:

Mathio,周杰倫< <學生的名字和姓氏

馬克,馬特< <學生的名字和姓氏

數學< <主題

這裏是我的代碼,仍然沒有工作:

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

回答

2

好像模板定義是錯誤內的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>'), 
+0

謝謝它的工作原理 – Noon 2013-05-14 07:58:22