dimanche 18 octobre 2015

Make maasaction field checkbox checked on some field value in Magento Grid

HI i have created a magento admin grid In this everything is working fine. But i am not getting how can i make the maas action checkbox field checked by default on the basis of some field value. Please look at the scrrenshot http://ift.tt/1NPwJTU

My code structure is

<?php

class Iclp_Cusgrid_Block_Adminhtml_Cusgrid_Grid extends Mage_Adminhtml_Block_Widget_Grid
{

        public function __construct()
        {
                parent::__construct();
                $this->setId("cusgridGrid");
                $this->setDefaultSort("cusgrid_id");
                $this->setDefaultDir("DESC");
                $this->setSaveParametersInSession(true);
        }

        protected function _prepareCollection()
        {
                $collection = Mage::getModel("cusgrid/cusgrid")->getCollection();
                $this->setCollection($collection);
                return parent::_prepareCollection();
        }
        protected function _prepareColumns()
        {
                $this->addColumn("cusgrid_id", array(
                "header" => Mage::helper("cusgrid")->__("ID"),
                "align" =>"right",
                "width" => "50px",
                "type" => "number",
                "index" => "cusgrid_id",
                ));

                $this->addColumn("region", array(
                "header" => Mage::helper("cusgrid")->__("region"),
                "index" => "region",
                ));
                $this->addColumn("regioncode", array(
                "header" => Mage::helper("cusgrid")->__("regioncode"),
                "index" => "regioncode",
                ));
                $this->addColumn("status", array(
                "header" => Mage::helper("cusgrid")->__("regioncode"),
                "index" => "regioncode",
                ));
                $this->addColumn("status", array(
                "header" => Mage::helper("cusgrid")->__("status"),
                "index" => "status",
                ));
            $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV')); 
            $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));

                return parent::_prepareColumns();
        }

        public function getRowUrl($row)
        {
               return $this->getUrl("*/*/edit", array("id" => $row->getId()));
        }



        protected function _prepareMassaction()
        {
            $this->setMassactionIdField('cusgrid_id');
            $this->getMassactionBlock()->setFormFieldName('cusgrid_ids');
            $this->getMassactionBlock()->setUseSelectAll(true);
            $this->getMassactionBlock()->addItem('Delete', array(
                     'label'=> Mage::helper('cusgrid')->__('Remove Cusgrid'),
                     'url'  => $this->getUrl('*/adminhtml_cusgrid/massRemove'),
                     'confirm' => Mage::helper('cusgrid')->__('Are you sure?')
                ));
            $this->getMassactionBlock()->addItem('Exclude', array(
                     'label'=> Mage::helper('cusgrid')->__('Exclude'),
                     'url'  => $this->getUrl('*/adminhtml_cusgrid/exclude'),
                     'confirm' => Mage::helper('cusgrid')->__('Are you sure?')
                ));
            return $this;
        }


}

can you please suggest me how can i do this.

thanks




Aucun commentaire:

Enregistrer un commentaire