in need to add state columns and get state name from region id so i used object manager for it but that not right way i convert that in constructor method the data of state comes but the column of grid was hide.
how can i add constructor method in this ??
<?php
namespace vendor\mpdule\Ui\Component\Listing\Column;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Listing\Columns\Column;
class State extends Column
{
public function prepareDataSource(array $dataSource)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$countryFactory = $objectManager->get('Magento\Directory\Model\CountryFactory')->create();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
if(isset($dataSource['data']['items'])) {
foreach($dataSource['data']['items'] as &$items) {
$regionId = $items['state'];
$region = $objectManager->create('Magento\Directory\Model\Region')
->load($regionId);
$items['state'] = $region['name'];
}
}
return $dataSource;
}
}