Backend\Core\Engine\DataGrid::setMassActionCheckboxes PHP Method

setMassActionCheckboxes() public method

Sets the checkboxes for the mass action
public setMassActionCheckboxes ( string $column, string $value, array $excludedValues = null, array $checkedValues = null )
$column string The name for the column that will hold the checkboxes.
$value string The value for the checkbox.
$excludedValues array The values that should be excluded.
$checkedValues array The values that should be checked.
    public function setMassActionCheckboxes($column, $value, array $excludedValues = null, array $checkedValues = null)
    {
        // build label and value
        $label = '<input type="checkbox" name="toggleChecks" value="toggleChecks" />';
        $value = '<input type="checkbox" name="id[]" value="' . $value . '" class="inputCheckbox" />';
        // add the column
        $this->addColumn($column, $label, $value);
        // set as first column
        $this->setColumnsSequence($column);
        // excluded IDs found
        if (!empty($excludedValues)) {
            // fetch the datagrid attributes
            $attributes = $this->getAttributes();
            // set if needed
            if (!isset($attributes['id'])) {
                $this->setAttributes(array('id' => 'table_' . time()));
            }
            // fetch the datagrid attributes
            $attributes = $this->getAttributes();
            // build array
            $excludedData['id'] = $attributes['id'];
            $excludedData['JSON'] = json_encode($excludedValues);
            // assign the stack to the datagrid template
            $this->tpl->assign('excludedCheckboxesData', $excludedData);
        }
        // checked IDs found
        if (!empty($checkedValues)) {
            // fetch the datagrid attributes
            $attributes = $this->getAttributes();
            // set if needed
            if (!isset($attributes['id'])) {
                $this->setAttributes(array('id' => 'table_' . time()));
            }
            // fetch the datagrid attributes
            $attributes = $this->getAttributes();
            // build array
            $checkedData['id'] = $attributes['id'];
            $checkedData['JSON'] = json_encode($checkedValues);
            // assign the stack to the datagrid template
            $this->tpl->assign('checkedCheckboxesData', $checkedData);
        }
    }