Livetable Checkbox Column Macro. Set checkboxes programmatically

Hi!

А piece of code:

addCheckboxToRow : function(event) {
var row = event.memo.row;

if(!row.down('input[name=checkboxSelect]')) {

  // The column could be hidden -> inthat case, row doesn't have a corresponding td element for that column
  // This is why we're using the JSON data
  var data = event.memo.data;

  // Col name has to match the one in JSON
  var dataColName = this.columnName.replace(/doc./g, 'doc_')

  // Get the row value for the given column
  var rowValue = data[dataColName + '_value'];
  if(typeof rowValue === "undefined") {
    // Default values like doc_fullName ...
    rowValue = data[dataColName];
  }
  if(typeof rowValue !== "undefined") {
    var checkboxSelect = new Element('input', {'type' : 'checkbox', 'name' : 'checkboxSelect', 'value' : rowValue, 'class' : 'chk_class'});
    this.cbValuesContainer.select('input').each(function(input){
      if(input.value === rowValue) {
        checkboxSelect.checked = true;
      }
    });
    row.insert({'top' : checkboxSelect});
    checkboxSelect.observe('change', function(event){
      if(checkboxSelect.checked) {
        var inputElem = new Element('input', {'name' : this.tableId + '-cb', 'value' : rowValue});
        this.cbValuesContainer.insert({'bottom' : inputElem});
      } else {
        this.cbValuesContainer.select('input').each(function(input){
          if(input.value === rowValue) {
            input.parentNode.removeChild(input);
          }
        });
      }
    }.bind(this));
  }
}

},

Is it possible get a checkbox state from field according this:

.....
if(typeof rowValue !== "undefined") {
    var checkboxSelect = new Element('input', {'type' : 'checkbox', 'name' : 'checkboxSelect', 'value' : rowValue, 'class' : 'chk_class'});
    this.cbValuesContainer.select('input').each(function(input){
      if(input.value === rowValue) {
        checkboxSelect.checked = true;
      }
    });
......

Thanks…

Fixed…

Hello!

How did you fixed it?