qooxdoo - 自定义listitem小部件选择

我制作了自定义listitem视图(基于http://news.qooxdoo.org/tutorial-part-4-2-custom-widgets-4)。 我对此列表中的选择项有疑问。始终选择第一个元素(无论列表中哪个元素我都会点击)。 我该怎么做才能解决我的问题? 这是我的列表项小部件: qx.Class.define(“project.MyView”,{     extend:qx.ui.core.Widget,     包括:[qx.ui.form.MModelProperty],     construct:function(){         this.base(参数);         var layout = new qx.ui.layout.Grid(4,2);         layout.setColumnFlex(1,1);         this._setLayout(布局);         this._createChildControl( “图标”);         this._createChildControl( “日期”);         this._createChildControl( “描述”);     },     属性:{         外观:{             精炼:真的,             init:“listitem”         },         icon:{             检查:“字符串”,             申请:“_ applyIcon”,             可空的:真的         },         日期:{             检查:“字符串”,             申请:“_ applyDate”,             可空的:真的         },         说明:{             检查:“字符串”,             申请:“_ applyDescription”,             可空的:真的         }     },     成员:{         _createChildControlImpl:function(id){             变量控制;             switch(id){             案例“图标”:                 control = new qx.ui.basic.Image(this.getIcon());                 control.setAnonymous(真);                 this._add(control,{                     行:0,                     栏:0,                     rowSpan:2                 });                 打破;             案件“日期”:                 control = new qx.ui.basic.Label(this.getDate());                 control.setAnonymous(真);                 this._add(control,{                     行:0,                     专栏:2                 });                 打破;             案例“描述”:                 control = new qx.ui.basic.Label(this.getDescription());                 control.setAnonymous(真);                 control.setRich(真);                 this._add(control,{                     行:0,                     专栏:1                 });                 打破;             }             返回控制|| this.base(arguments,id);         },         _applyIcon:function(value,old){             var icon = this.getChildControl(“icon”);             icon.setSource(值);         },         _applyDescription:function(value,old){             var description = this.getChildControl(“description”);             description.setValue(值);         },         _applyDate:function(value,old){             var date = this.getChildControl(“date”);             date.setValue(值);         }     },     destruct:function(){     } }); ......在这里我如何使用它: this.list = new qx.ui.form.List(); this.listController = new qx.data.controller.List(null,this.list); this.listController.setDelegate({     createItem:function(){         返回新项目.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( “图标”)setWidth(48)。         item.getChildControl( “图标”)自动调用setHeight(48)。         item.getChildControl( “图标”)setScale(真)。         item.setMinHeight(52);     } });     
已邀请:
看起来问题出在bindItem函数中。只要提供自己的bindItem函数,就不再绑定所有默认绑定属性。这意味着标签,图标和模型不再同步。我没有尝试过你的代码,但我想通过简单的模型绑定,问题就会消失。
controller.bindProperty("", "model", null, item, id);
如果您想在模型属性中使用不同的东西,并且在您的选择中需要这样做,则这是必要的。此代码行只使用整个对象作为模型,在大多数情况下这是一个好主意。 最好, 马丁     

要回复问题请先登录注册