Posted by John Smith
on 10.01.2008 14:42
Hi,

i have built an ajax live grid and i want to use a checkbox in the
table.
So i have found this source code (ext7.php) to create a checkbox in a
column in the table:

columnSpecs   : [{canHide:false,type:'control',control:new
Rico.TableColumn.checkbox('CHECKEDVALUE','UNCHECKEDVALUE',
'DEFAULTVALUE')}]

The problem is, that I want to set the name of the checkbox on myself,
the name of the checkbox must be "toDelete[]" and the value of every
checkbox should be a value which is requested by the ajax request (the
value will be the primary key of the row).

So I want to build a delete checkbox array.

How can I do this?
Posted by Mark Moran
on 10.01.2008 18:49
Matt and I have recently been working on something that I think would 
address your need. It uses whatever values the data source provides for 
that column and creates a list of the values that have been checked. It 
hasn't made it into the SVN yet, but I hope it will shortly. -Mark
Posted by John Smith
on 11.01.2008 09:29
Thanks.

############################################################################
EDIT:

I've found the problem:
If I rename the checkbox name, the '_onlick' function in
'Rico.TableColumn.checkbox' can not use the windowRow, because it gets
the windowRow with the checkbox name. Is there a other possibility?

Can I set a user defined onclick function to the checkboxes?
############################################################################


Now I modifed the ricoLiveGrid.js:

For user defined checkboxe names:

Rico.TableColumn.checkbox.prototype = {

checkbox names
  initialize: function(checkedValue, uncheckedValue, defaultValue,
readOnly, checkboxName) {
    this._checkedValue=checkedValue;
    this._uncheckedValue=uncheckedValue;
    this._defaultValue=defaultValue || false;
    this._readOnly=readOnly || false;
    this._checkboxName=checkboxName;
    this._checkboxes=[];
  },

  _create: function(gridCell,windowRow) {

    if (this._checkboxName == undefined)
    {
        var checkboxName =
this.liveGrid.tableId+'_chkbox_'+this.index+'_'+windowRow;
    } else {
        var checkboxName = this._checkboxName;
    }

this._checkboxes[windowRow]=RicoUtil.createFormField(gridCell,'input','checkbox',checkboxName);
.....


For values from the ajax request as a value in a checkbox:

In Rico.TableColumn.checkbox:

  _display: function(v,gridCell,windowRow) {
      this._checkboxes[windowRow].checked=(v==this._checkedValue);

      // 11.01.2008, Baris: Enable checkbox values from ajax request
      var
getWindowValue=this.liveGrid.buffer.getWindowValue.bind(this.liveGrid.buffer);
      this._checkboxes[windowRow].value=this._checkedValue.replace(/\{\d+\}/g,
      function ($1) {
          var colIdx=parseInt($1.substr(1));
          return getWindowValue(windowRow,colIdx);
      }
      );
  }

It works fine, but if I click on a checkbox Firefox says:

this.rows[bufRow] has no properties
if (!this.rows[bufRow][col]) this.rows[bufRow][col]={};

I think the '_onclick' method in 'Rico.TableColumn.checkbox' is the
problem, but why?
Posted by Matt Brown
on 23.01.2008 04:27
The function you need is now checked into SVN. Take a look at 
Rico.TableColumn.checkboxKey.

If you need the svn link, just search these forums for "svn".

Matt