mercredi 30 septembre 2015

Make checkbox selected on the basis of some field parameter in grid Magento

Hi i have created a custom grid using a silksoftware.which works fine. Now i need to make the check-box selected on the basis of some condition.Like say if i have a collection of 10 entries and i have selected 5 out of them and change there values with mass action. Now i need to show those 5 as selected in check-box. Can you please suggest me how can i do this.

My grid file is as below

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->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('remove_cusgrid', array(
                     'label'=> Mage::helper('cusgrid')->__('Remove Cusgrid'),
                     'url'  => $this->getUrl('*/adminhtml_cusgrid/massRemove'),
                     'confirm' => Mage::helper('cusgrid')->__('Are you sure?')
                ));
            return $this;
        }


}




Aucun commentaire:

Enregistrer un commentaire