Selection qooxdoo-自定义listitem小部件选择

Selection qooxdoo-自定义listitem小部件选择,selection,listitem,qooxdoo,Selection,Listitem,Qooxdoo,我自定义了listitem视图(基于) 我对此列表中的选择项有问题。始终会选择第一个元素(无论单击列表中的哪个元素) 我应该做些什么来解决我的问题 以下是我的列表项小部件: qx.Class.define("project.MyView", { extend : qx.ui.core.Widget, include : [qx.ui.form.MModelProperty], construct : function() { this.base(argu

我自定义了listitem视图(基于)

我对此列表中的选择项有问题。始终会选择第一个元素(无论单击列表中的哪个元素)

我应该做些什么来解决我的问题

以下是我的列表项小部件:

qx.Class.define("project.MyView", { extend : qx.ui.core.Widget, include : [qx.ui.form.MModelProperty], construct : function() { this.base(arguments); var layout = new qx.ui.layout.Grid(4, 2); layout.setColumnFlex(1, 1); this._setLayout(layout); this._createChildControl("icon"); this._createChildControl("date"); this._createChildControl("description"); }, properties : { appearance : { refine : true, init : "listitem" }, icon : { check : "String", apply : "_applyIcon", nullable : true }, date : { check : "String", apply : "_applyDate", nullable : true }, description : { check : "String", apply : "_applyDescription", nullable : true } }, members : { _createChildControlImpl : function(id) { var control; switch (id) { case "icon": control = new qx.ui.basic.Image(this.getIcon()); control.setAnonymous(true); this._add(control, { row : 0, column : 0, rowSpan : 2 }); break; case "date": control = new qx.ui.basic.Label(this.getDate()); control.setAnonymous(true); this._add(control, { row : 0, column : 2 }); break; case "description": control = new qx.ui.basic.Label(this.getDescription()); control.setAnonymous(true); control.setRich(true); this._add(control, { row : 0, column : 1 }); break; } return control || this.base(arguments, id); }, _applyIcon : function(value, old) { var icon = this.getChildControl("icon"); icon.setSource(value); }, _applyDescription : function(value, old) { var description = this.getChildControl("description"); description.setValue(value); }, _applyDate : function(value, old) { var date = this.getChildControl("date"); date.setValue(value); } }, destruct : function() { } }); qx.Class.define(“project.MyView”{ 扩展:qx.ui.core.Widget, 包括:[qx.ui.form.MModelProperty], 构造:函数(){ 这是基础(参数); var布局=新的qx.ui.layout.Grid(4,2); 布局。setColumnFlex(1,1); 本._设置布局(布局); 这是._createChildControl(“图标”); 此项控制(“日期”); 此项。_createChildControl(“说明”); }, 特性:{ 外观:{ 是的, 初始化:“列表项” }, 图标:{ 勾选:“字符串”, 应用:“_applyIcon”, 可为空:真 }, 日期:{ 勾选:“字符串”, 应用:“_applyDate”, 可为空:真 }, 说明:{ 勾选:“字符串”, 应用:“\u applyDescription”, 可为空:真 } }, 成员:{ _createChildControlImpl:函数(id){ var控制; 开关(id){ 案例“图标”: control=newqx.ui.basic.Image(this.getIcon()); control.setAnonymous(true); 这个.\u添加(控制{ 行:0, 列:0, 行距:2 }); 打破 案件“日期”: control=newqx.ui.basic.Label(this.getDate()); control.setAnonymous(true); 这个.\u添加(控制{ 行:0, 栏目:2 }); 打破 案例“说明”: control=新的qx.ui.basic.Label(this.getDescription()); control.setAnonymous(true); control.setRich(true); 这个.\u添加(控制{ 行:0, 栏目:1 }); 打破 } 返回控件| | this.base(参数,id); }, _applyIcon:函数(值,旧){ var icon=this.getChildControl(“icon”); icon.setSource(值); }, _applyDescription:函数(值,旧){ var description=this.getChildControl(“description”); 说明.设定值(值); }, _applyDate:函数(值,旧){ var date=此.getChildControl(“日期”); 日期。设置值(值); } }, 析构函数{ } }); 。。。下面是我如何使用它:

this.list = new qx.ui.form.List(); this.listController = new qx.data.controller.List(null, this.list); this.listController.setDelegate({ createItem : function() { return new project.MyView(); }, bindItem : function(controller, item, id) { controller.bindProperty("description", "description", null,item, id); controller.bindProperty("icon", "icon", null, item, id); controller.bindProperty("date", "date", null, item, id); }, configureItem : function(item) { item.getChildControl("icon").setWidth(48); item.getChildControl("icon").setHeight(48); item.getChildControl("icon").setScale(true); item.setMinHeight(52); } }); this.list=新的qx.ui.form.list(); this.listController=new qx.data.controller.List(null,this.List); this.listController.setDelegate({ createItem:function(){ 返回新的project.MyView(); }, bindItem:函数(控制器、项、id){ controller.bindProperty(“description”、“description”、null、item、id); controller.bindProperty(“icon”、“icon”、null、item、id); controller.bindProperty(“日期”,“日期”,null,item,id); }, configureItem:功能(项){ 项目.getChildControl(“图标”).setWidth(48); 项目。getChildControl(“图标”)。设置高度(48); item.getChildControl(“图标”).setScale(真); 项目.设置最小高度(52); } });
看起来问题出在bindItem函数中。一旦您提供了自己的bindItem函数,所有默认绑定属性就不再绑定。这意味着标签、图标和模型不再同步。我还没有试过你的代码,但是我想通过一个简单的模型绑定,这个问题就会消失

controller.bindProperty("", "model", null, item, id);
如果您希望模型属性中有不同的内容,例如,在您的选择中,这是必需的。此代码行仅使用整个对象作为模型,这在大多数情况下是一个好主意

最好的, 马丁