2016-10-13 22 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

相关问题