0

Is there any way to make all checkboxes checked in particular column in admin grid.

I want checkboxes checked by default in "skip" column. Here is a code for this column:

protected function _prepareColumns()
{
    parent::_prepareColumns();

    $this->addColumn('skip', array(
        'header'     => Mage::helper('importexport')->__('Skip'),
        'type'       => 'checkbox',
        'name'       => 'skip',
        'field_name' => Mage_ImportExport_Model_Export::FILTER_ELEMENT_SKIP . '[]',
        'filter'     => false,
        'sortable'   => false,
        'align'      => 'center',
        'index'      => 'attribute_id'
    ));

   //other columns here

    if ($this->hasOperation()) {
        $operation = $this->getOperation();
        $skipAttr = $operation->getSkipAttr();
        if ($skipAttr) {
            $this->getColumn('skip')
                ->setData('values', $skipAttr);
        }
        $filter = $operation->getExportFilter();
        if ($filter) {
            $this->getColumn('filter')
                ->setData('values', $filter);
        }
    }

    return $this;
}
2

Try This

$this->addColumn('skip', array(
        'header'     => Mage::helper('importexport')->__('Skip'),
        'type'       => 'checkbox',
        'name'       => 'skip',
        'field_name' => Mage_ImportExport_Model_Export::FILTER_ELEMENT_SKIP . '[]',
        'filter'     => false,
        'sortable'   => false,
        'align'      => 'center',
        'index'      => 'attribute_id',
        'values'      => array(1,2) // add your values here
));

just add key 'values' => array(1,2) // your values

If you want default checked value for all you need to pass all value in array or make new Grid Column Renderer

| improve this answer | |
  • Isn't that the same thing? $this->getColumn('skip') ->setData('values', $skipAttr); – br33f Mar 17 '16 at 12:43
  • yes that should work. try it out – Minesh Patel Mar 17 '16 at 12:52
  • Nope, it doesn't work. – br33f Mar 18 '16 at 15:29
  • from where you are calling $this->getColumn('skip') ->setData('values', $skipAttr); ? – Minesh Patel Mar 21 '16 at 4:21
  • Do you guys know how to do this exactly? because i'm on this situation and dont know how to do that, on catalog_category_product, they can checkbox checked, but i'm follow them and doesn't checked at all. @@ the values i put in is a array just like them did. Like this (1,2) – fudu Aug 11 '18 at 8:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.