'Store / Website Column in Magento 2 Admin Grid - Custom Module
I have created a custom module in magento 2. I have two tables, first one is the main table and the other one is for the stores. The second table has the foreign key constraint of the first table's primary key and the store id column. I have successfully created the gird and the form. The only problem that I am having is that I am not able to load store ids in the grid. I am using ui_component approach, means, the grid is being rendered using xml.
Solution 1:[1]
Check Magento\Cms\Block\Adminhtml\Page\Grid
/**
* Check is single store mode
*/
if (!$this->_storeManager->isSingleStoreMode()) {
$this->addColumn(
'store_id',
[
'header' => __('Store View'),
'index' => 'store_id',
'type' => 'store',
'store_all' => true,
'store_view' => true,
'sortable' => false,
'filter_condition_callback' => [$this, '_filterStoreCondition']
]
);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Silpion |