shippingbar_post_listing.xml
<column name="status">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">CM\Shippingbar\Model\Status</item>
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Status</item>
</item>
</argument>
</column>
CM\Shippingbar\Model\Status.php
<?php
namespace CM\Shippingbar\Model;
use Magento\Framework\Data\OptionSourceInterface;
/**
* ProductStatus Class
*/
class Status implements OptionSourceInterface
{
/**
* @var \CM\Shippingbar\Model\Productlabel
*/
protected $model;
/**
* Constructor
*
* @param \CM\Shippingbar\Model\ModelFile $model
*/
protected function _construct(\CM\Shippingbar\Model\Shippingbar $model)
{
$this->model = $model;
}
/**
* Get options
*
* @return array
*/
public function toOptionArray()
{
$options[] = ['label' => '', 'value' => ''];
$availableOptions =$this->model->getAvailableStatuses();
foreach ($availableOptions as $key => $value) {
$options[] = [
'label' => $value,
'value' => $key,
];
}
return $options;
}
}
CM\Shippingbar\Model\Shippingbar.php
<?php
namespace CM\Shippingbar\Model;
class Shippingbar extends \Magento\Framework\Model\AbstractModel
{
const STATUS_ENABLED = 1;
const STATUS_DISABLED = 0;
protected function _construct()
{
$this->_init('CM\Shippingbar\Model\ResourceModel\Shippingbar');
}
public function getAvailableStatuses()
{
return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')];
}
}