i made custom listitem view (based on http://news.qooxdoo.org/tutorial-part-4-2-custom-widgets-4).
i have problem selection items on list. there selected first element (no matter element on list click).
what should resolve problem?
here list-item widget:
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() { } });
... , here how use it:
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); } });
looks problem in binditem function. supply own binditem function, default bound properties not bound anymore. means lable, icon , model no longer in sync. havent tried code guess simple binding of model, problem gone.
controller.bindproperty("", "model", null, item, id);
this necessary in case want different in model property , that, in selection example. code line uses whole object model in cases idea.
best, martin
Comments
Post a Comment