Get KoolPHP UI with 30% OFF!

Checkbox implementation GridBooleanColumn

Brain
I want to make use of the checkbox feature on the GridBooleanColumn thus this block of code
$column->UseCheckBox =true;
if i use the above code on the control it turns the control to check alright but when the checkbox is checked it does not listen to event.
The code below can be found in the koolgrid
class GridBooleanColumn extends GridColumn {
var $TrueText = "True";
var $FalseText = "False";
var $UseCheckBox =false;

function Render($_row) {
$_cell ="";
if ($this->UseCheckBox) {

$_tpl_cell = "<span class='kgrECap'><input id='{id}' name='{id}' type='checkbox' value='{valued}' {checked} /></span>";
$_cell = _replace("{id}", $_row->_UniqueID . "_" . $this->_UniqueID . "_input", $_tpl_cell);
$_cell = _replace("{checked}", ($this->Format($_row->DataItem[$this->DataField])=='t') ? "checked" : "", $_cell);
$_cell = _replace("{valued}", ($this->Format($_row->DataItem[$this->DataField])=='t') ? '1' :'0', $_cell);
} else {
if($this->Format($_row->DataItem[$this->DataField])!=null){
$_cell = ($this->Format($_row->DataItem[$this->DataField])=='t') ? $this->TrueText : $this->FalseText;
}

}
return $_cell;
}
function InlineEditRender($_row, $_is_form_render = false) {
if (!$this->ReadOnly) {
$_cell = "";
if ($this->UseCheckBox) {
$_tpl_cell = "<span class='kgrECap'><input id='{id}' name='{id}' type='checkbox' value='{valued}' {checked} /></span>";
$_cell = _replace("{id}", $_row->_UniqueID . "_" . $this->_UniqueID . "_input", $_tpl_cell);
$_cell = _replace("{checked}", ($this->Format($_row->DataItem[$this->DataField])=='t')? "checked" : "", $_cell);
$_cell = _replace("{valued}", ($this->Format($_row->DataItem[$this->DataField])=='t')? "1" : "0", $_cell);
} else {
$_tpl_select = "<span class='kgrECap'><select id='{id}' name='{id}' style='width:{width}'>{options}</select></span>";
$_tpl_option = "<option value='{value}' {selected}>{text}</option>";
$_true_option = _replace("{value}", "1", $_tpl_option);
$_true_option = _replace("{selected}",$this->Format($_row->DataItem[$this->DataField])=='t'? "selected" : "", $_true_option);
$_true_option = _replace("{text}", $this->TrueText, $_true_option);
$_false_option = _replace("{value}", "0", $_tpl_option);
$_false_option = _replace("{selected}",$this->Format($_row->DataItem[$this->DataField])=='f'? "selected" : "", $_false_option);
$_false_option = _replace("{text}", $this->FalseText, $_false_option);
$_cell = _replace("{id}", $_row->_UniqueID . "_" . $this->_UniqueID . "_input", $_tpl_select);
$_cell = _replace("{options}", $_true_option . $_false_option, $_cell);
$_cell = _replace("{width}", ($_is_form_render) ? "90%" : "100%", $_cell);
}
return $_cell;
} else {
return $this->Render($_row);
}
}
function FormEditRender($_row) {
return $this->InlineEditRender($_row, true);
}
function GetEditValue($_row) {
if ($this->UseCheckBox) {
return isset($_POST[$_row->_UniqueID . "_" . $this->_UniqueID . "_input"]) ? 1 : 0;
} else {
return parent::GetEditValue($_row);
}
}
function RenderFilter($_filter = null) {
if (! $_filter)
$_filter = $this->Filter;
$_cell = "";
if ($this->UseCheckBox) {
$_tpl_cell = "<span class='kgrECap'><input id='{id}' name='{id}[]' type='checkbox' {checked} onchange='grid_filter_trigger(\"{colid}\",this)' /></span>";
$_cell = _replace("{id}", $this->_UniqueID . "_filter_input", $_tpl_cell);
$_cell = _replace("{colid}", $this->_UniqueID, $_cell);
$_cell = _replace("{checked}", ($this->Filter["Value"]) ? "checked" : "", $_cell);
} else {
$_tpl_select = "<span class='kgrECap'><select id='{id}' name='{id}' style='width:100%' onchange='grid_filter_trigger(\"{colid}\",this)'>{options}</select></span>";
$_tpl_option = "<option value='{value}' {selected}>{text}</option>";
$_true_option = _replace("{value}", "1", $_tpl_option);
$_true_option = _replace("{selected}", ($this->Filter["Value"]) ? "selected" : "", $_true_option);
$_true_option = _replace("{text}", $this->TrueText, $_true_option);
$_false_option = _replace("{value}", "0", $_tpl_option);
$_false_option = _replace("{selected}", (!$this->Filter["Value"]) ? "selected" : "", $_false_option);
$_false_option = _replace("{text}", $this->FalseText, $_false_option);
$_cell = _replace("{id}", $this->_UniqueID . "_filter_input", $_tpl_select);
$_cell = _replace("{colid}", $this->_UniqueID, $_cell);
$_cell = _replace("{options}", $_true_option . $_false_option, $_cell);
}
return $_cell;
}
function GetFilterValue($_value = null) {
if ($this->UseCheckBox) {
if (! $_value)
$_value = isset($_POST[$this->_UniqueID . "_filter_input"][0]) ? 1 : 0;
return $_value;
} else {
return parent::GetFilterValue();
}
}
function CreateInstance($_instance = null) {
if ($_instance === null) {
$_instance = new GridBooleanColumn();
}
parent::CreateInstance($_instance);
$_instance->TrueText = $this->TrueText;
$_instance->FalseText = $this->FalseText;
$_instance->UseCheckBox = $this->UseCheckBox;
return $_instance;
}
}
please which section of the code should modify in order to get it working
Posted Oct 29, 2018 Kool