Recently, I have created custom module without UI component. I want to add store view field on that. I have added in form easily but put me in trouble little bit during grid. To show multiple store in admin custom module grid, I have used renderer
and following changes in grid.php
file
Custom\Slider\Block\Adminhtml\Slide\Grid.php
$this->addColumn(
'store_ids',
[
'header' => __('Store Views'),
'index' => 'store_ids',
'type' => 'store',
'store_all' => true,
'store_view' => true,
'renderer'=> 'Custom\Slider\Block\Adminhtml\Slide\Edit\Tab\Renderer\Store',
'filter_condition_callback' => [$this, '_filterStoreCondition']
]
);
Custom\Slider\Block\Adminhtml\Slide\Edit\Tab\Renderer\Store.php
', $scopes) . __(' [deleted]');
return $out;
}
if (empty($origStores) && !$skipEmptyStoresLabel) {
return '';
}
if (!is_array($origStores)) {
$origStores = [$origStores];
}
if (empty($origStores)) {
return '';
} elseif (in_array(0, $origStores) && count($origStores) == 1 && !$skipAllStoresLabel) {
return __('All Store Views');
}
$data = $this->_getStoreModel()->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$out .= $website['label'] . '
';
foreach ($website['children'] as $group) {
$out .= str_repeat(' ', 3) . $group['label'] . '
';
foreach ($group['children'] as $store) {
$out .= str_repeat(' ', 6) . $store['label'] . '
';
}
}
}
return $out;
}
/**
* Render row store views for export
*
* @param \Magento\Framework\DataObject $row
* @return \Magento\Framework\Phrase|string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function renderExport(\Magento\Framework\DataObject $row)
{
$out = '';
$skipAllStoresLabel = $this->_getShowAllStoresLabelFlag();
// $origStores = $row->getData($this->getColumn()->getIndex());
$origStores = explode(',',$row->getData($this->getColumn()->getIndex()));
if ($origStores === null && $row->getStoreName()) {
$scopes = [];
foreach (explode("\n", $row->getStoreName()) as $k => $label) {
$scopes[] = str_repeat(' ', $k * 3) . $label;
}
$out .= implode("\r\n", $scopes) . __(' [deleted]');
return $out;
}
if (!is_array($origStores)) {
$origStores = [$origStores];
}
if (in_array(0, $origStores) && !$skipAllStoresLabel) {
return __('All Store Views');
}
$data = $this->_getStoreModel()->getStoresStructure(false, $origStores);
foreach ($data as $website) {
$out .= $website['label'] . "\r\n";
foreach ($website['children'] as $group) {
$out .= str_repeat(' ', 3) . $group['label'] . "\r\n";
foreach ($group['children'] as $store) {
$out .= str_repeat(' ', 6) . $store['label'] . "\r\n";
}
}
}
return $out;
}
}
Output : 
Cheers !!!