how to Store Values In Database for Custom Grid Serializer (Customer)?
-
05-10-2020 - |
Question
I am Created Custom Module for Customer Grid Serializer and now I want to Store That Values in Diffrent Table. Can Any one Help me? Any Kind of help will appreiciated.
My Grid Code : app/code/local/Sigmasolve/Recipe/Block/Adminhtml/Recipe/Edit/Tab
<?php
class Sigmasolve_Recipe_Block_Adminhtml_Recipe_Edit_Tab_Customers extends Mage_Adminhtml_Block_Widget_Grid
{
public function __construct()
{
parent::__construct();
$this->setSaveParametersInSession(false);
$this->setUseAjax(true);
$this->setId('recipe_customers');
}
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect();
$this->setCollection($collection);
return parent::_prepareCollection();
}
protected function _prepareColumns()
{
$this->addColumn('selected_customers', array(
'header' => $this->__('Popular'),
'type' => 'checkbox',
'index' => 'entity_id',
'align' => 'center',
'field_name'=> 'selected_customers',
'values' => $this->getSelectedCustomers(),
));
$this->addColumn('name', array(
'header' => $this->__('Name'),
'index' => 'name',
'align' => 'left',
));
return parent::_prepareColumns();
}
public function getGridUrl()
{
return $this->getUrl('*/*/customersGrid', array('_current' => true));
}
}
Solution
That will your custom grid field name orders
change it accordingly your name
$this->addColumn('selected_customers', array(
'header' => $this->__('Popular'),
'type' => 'checkbox',
'index' => 'entity_id',
'align' => 'center',
'name' => 'customers',
'field_name'=> 'selected_customers',
'values' => $this->getSelectedCustomers(),
));
if(isset($postData['links'])){
$customgrid = Mage::helper('adminhtml/js')->decodeGridSerializedInput($postData['links']['customers']); //Save the array to your database
$customgridvalues = implode(",", $customgrid);
}
complete example of grid
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange