【问题标题】:qooxdoo - custom listitem widget selectionqooxdoo - 自定义列表项小部件选择
【发布时间】:2010-12-20 20:13:21
【问题描述】:

我制作了自定义列表项视图(基于http://news.qooxdoo.org/tutorial-part-4-2-custom-widgets-4)。

我对此列表中的选择项目有疑问。总是选择第一个元素(无论我会点击列表中的哪个元素)。

我应该怎么做才能解决我的问题?

这是我的列表项小部件:

qx.Class.define("project.MyView", { 扩展:qx.ui.core.Widget, 包括:[qx.ui.form.MModelProperty], 构造:函数(){ this.base(参数); var layout = new qx.ui.layout.Grid(4, 2); layout.setColumnFlex(1, 1); this._setLayout(布局); this._createChildControl("icon"); this._createChildControl("date"); this._createChildControl("描述"); }, 特性 : { 外貌 : { 精炼:真, 初始化:“列表项” }, 图标 : { 检查:“字符串”, 应用:“_applyIcon”, 可为空:真 }, 日期 : { 检查:“字符串”, 申请:“_applyDate”, 可为空:真 }, 描述 : { 检查:“字符串”, 应用:“_applyDescription”, 可为空:真 } }, 成员:{ _createChildControlImpl:函数(id){ 变量控制; 开关(ID){ 案例“图标”: 控制 = 新 qx.ui.basic.Image(this.getIcon()); control.setAnonymous(true); this._add(控制,{ 行:0, 列:0, 行跨度:2 }); 休息; 案例“日期”: control = new qx.ui.basic.Label(this.getDate()); control.setAnonymous(true); this._add(控制,{ 行:0, 栏目:2 }); 休息; 案例“描述”: control = new qx.ui.basic.Label(this.getDescription()); control.setAnonymous(true); control.setRich(true); this._add(控制,{ 行:0, 栏目:1 }); 休息; } 返回控制 || this.base(参数,id); }, _applyIcon:函数(值,旧){ var icon = this.getChildControl("icon"); icon.setSource(值); }, _applyDescription:函数(值,旧){ var description = this.getChildControl("description"); 描述.setValue(值); }, _applyDate:函数(值,旧){ var date = this.getChildControl("date"); 日期.setValue(值); } }, 破坏:函数(){ } });

...以及我如何使用它:

this.list = new qx.ui.form.List(); this.listController = new qx.data.controller.List(null, this.list); this.listController.setDelegate({ 创建项目:函数(){ 返回新项目.MyView(); }, 绑定项目:函数(控制器,项目,ID){ controller.bindProperty("description", "description", null,item, id); controller.bindProperty("icon", "icon", null, item, id); controller.bindProperty("date", "date", null, item, id); }, 配置项目:功能(项目){ item.getChildControl("icon").setWidth(48); item.getChildControl("icon").setHeight(48); item.getChildControl("icon").setScale(true); item.setMinHeight(52); } });

【问题讨论】:

    标签: selection listitem qooxdoo


    【解决方案1】:

    看起来问题出在 bindItem 函数中。一旦您提供自己的 bindItem 函数,所有默认绑定属性都不再绑定。这意味着标签、图标和模型不再同步。我没有试过你的代码,但我想通过简单的模型绑定,问题就会消失。

    controller.bindProperty("", "model", null, item, id);
    

    如果您想要在模型属性中使用不同的东西,例如在您的选择中,这是必要的。此代码行仅使用整个对象作为模型,这在大多数情况下是个好主意。

    最好, 马丁

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-15
      • 1970-01-01
      • 2010-12-15
      • 2020-04-21
      • 1970-01-01
      • 2013-09-13
      • 2017-11-19
      相关资源
      最近更新 更多