Hi all,
I have a qx.ui.table.model.Simple column of Booleans (checkboxes). I'd like
to add a checkbox to the column header that will toggle the Boolean of that
column in all rows. I've tried to create my own Headercell  and
HeaderCellRenderer implementation but when I load the table I get a
"cachedWidget is undefined" error.

Here is the header cell implementation :
/**
 * @childControl check-box {qx.ui.form.CheckBox} checkbox for header cell
 * @childControl sort-icon {qx.ui.basic.Image} sort icon of the header cell
 */
qx.Class.define("prearchiveui.CheckboxHeaderCell",
{
  extend : qx.ui.container.Composite,
  construct : function () {
    this.base(arguments);
    var layout = new qx.ui.layout.Grid();
    layout.setRowFlex(0,1);
    layout.setColumnFlex(1, 1);
    this.setLayout(layout);
  },
  properties : {
    checkBox : {
      check : "qx.ui.form.CheckBox",
      init : null,
      nullable : true
    },
    /** The sort icon URL of the sorting indicator */
    sortIcon :{
      check : "String",
      init : null,
      nullable : true,
      apply : "_applySortIcon",
      themeable : true
    }
  },
  members : {
    _applyCheckBox : function (value,old) {
      if (value) {
    this._showChildControl("check-box").setValue(value);
      }
      else {
    this._excludeChildControl("check-box");
      }
    },
    _applySortIcon : function (value,old) {
      if (value) {
    this._showChildControl("sort-icon").setValue(value);
      }
      else {
    this._excludeChildControl("sort-icon");
      }
    },
    // overridden
    _createChildControlImpl : function(id)
    {
      var control;

      switch(id)
      {
        case "check-box":
      control = this.getCheckBox();
      if (control != null) {
        this._add(control, {row: 0, column: 0});
      }
          break;
        case "sort-icon":
          control = new qx.ui.basic.Image(this.getSortIcon());
          control.setAnonymous(true);
          this._add(control, {row: 0, column: 1});
          break;
      }
      return control || this.base(arguments, id);
    }
  }
});

And the cell renderer :
qx.Class.define("prearchiveui.CheckboxHeaderCellRenderer",
{
  extend : qx.core.Object,
  implement : qx.ui.table.IHeaderRenderer,
  construct : function (checkbox) {
    this.base(arguments);
    this.setCheckBox(checkbox);
  },

  properties : {
    checkBox : {
      check : "qx.ui.form.CheckBox"
    }
  },
  members : {
    createHeaderCell : function (cellInfo) {
      var widget = new prearchiveui.CheckboxHeaderCell();
      this.updateHeaderCell(cellInfo,widget);
    },
    updateHeaderCell : function  (cellInfo, widget) {
      var DefaultHeaderCellRenderer = qx.ui.table.headerrenderer.Default;
      cellInfo.sorted ?
        widget.addState(DefaultHeaderCellRenderer.STATE_SORTED) :
        widget.removeState(DefaultHeaderCellRenderer.STATE_SORTED);

      cellInfo.sortedAscending ?
        widget.addState(DefaultHeaderCellRenderer.STATE_SORTED_ASCENDING) :

widget.removeState(DefaultHeaderCellRenderer.STATE_SORTED_ASCENDING);
      widget.setCheckBox(this.getCheckBox());
    }
  }
});

Thanks for the feedback!
-deech
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in  U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store 
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to