2016-10-13 24 views
0

我有以下Webix組合:如何從Webix組合中的選定數據項獲取屬性?

{ 
    view: "combo", 
    label: 'Select the name', 
    labelWidth:130, 
    options: { 
    data:[ 
     { itemId:"120", itemName:"Name 1"}, 
     { itemId:"121", itemName:"Name 2"} 
    ], 
    body: { template: '#itemName#' }   
    }, 
    on:{ 
    onChange:function(id){ alert(id) } 
    } 
} 

它看起來就像必要的,但我怎麼能選擇新的項目後得到itemId?我只能得到自動生成的ID

同樣的代碼片段:

http://webix.com/snippet/3a431f1c

提前感謝!

回答

1

你必須得到組合框的對象,然後你可以用它的getItem()方法的幫助下獲得所選項目的數據:

var obj = this.getPopup().getBody().getItem(newValue); //the object 
var id = obj.itemId; //the desired id which is itemId in your code 

請檢查片斷here

+0

謝謝! (:在仔細檢查文檔後發現'getList()'而不是'getPopup()。getBody()',但兩者的工作方式是一樣的。 – Amarillo

+0

是的,我忘了提到這一點。但是,你有解決方案:) – jayantish

相關問題