Please find below a class which can be used by any one who wants to 
achieve the functionality of a checkbox inside a table:-

qx.Class.define("CheckboxInsideTable",
{
     extend : qx.ui.table.Table,
// Controller is the *this* keyword stating the scope, and the *data* is 
an object consisting of 2 arrays containing the Metadata and the Acutal 
Data present in the Table.
     construct : function(controller, data)  {
      this._controller = controller;
      for(var i = 0; i < data.meta.length; i++) {
      this.columnIds[i] =  data.meta[i].dataIndex;
      this.columnNames[data.meta[i].dataIndex] = data.meta[i].name;
   }
    this._tableModel = new qx.ui.table.model.Simple();
  this._tableModel.setColumnIds( this.columnIds );
  this._tableModel.setColumnNamesById( this.columnNames );
  var columnModel = this.getTableColumnModel();
  var columnModel = this.getTableColumnModel();
  var propertyCellRendererFactory = new 
qx.ui.table.cellrenderer.Dynamic(this.propertyCellRendererFactoryFunc);
  var propertyCellEditorFactory = new 
qx.ui.table.celleditor.Dynamic(this.propertyCellEditorFactoryFunc);
  columnModel.setDataCellRenderer(2, propertyCellRendererFactory);
  columnModel.setCellEditorFactory(2, propertyCellEditorFactory);
  this._tableModel.setDataAsMapArray(data.rows, true);
  this.addEventListener("cellClick",this._onCellCilck, this );

members :
{
      columnIds : [],
      columnNames : {},
          propertyCellEditorFactoryFunc : function (cellInfo)
   {
       return new qx.ui.table.celleditor.CheckBox;
   },

       propertyCellRendererFactoryFunc : function (cellInfo)
  {
      return new qx.ui.table.cellrenderer.Boolean;
  },

     _onCellCilck : function(e)
{
       var colnum = e.getColumn();
       var romnum = e.getRow();
       if ( this.getTableModel().getValue(colnum,romnum) == true )
           {
               this.getTableModel().setValue(colnum,romnum,false);
            }
           else
           {
                this.getTableModel().setValue(colnum,romnum,true);
            }
  }
}

});

Any user can use this class and pass the data in the constructor and he 
will get the desired functionality depending on the column number he 
enetered in the columnModel.setDataCellRenderer and 
columnModel.setCellEditorFactory properties respectively.

I Hope this helps to any user struggling to implement a checkbox inside 
the table.

Regards,
Gaurav

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to