How to show row status Enbale or Disable in uicomponent grid in magento

How to show row status Enbale or Disable in uicomponent grid in magento

Hello friend todays im share How to show row status Enbale or Disable in uicomponent grid in magento

Add this code in uicomonent grid - 


 <column name="status">

    <argument name="data" xsi:type="array">

        <item name="options" xsi:type="object">Mageget\WebPushNotification\Model\Status</item>

        <item name="config" xsi:type="array">

            <item name="filter" xsi:type="string">select</item>

            <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>

            <item name="dataType" xsi:type="string">select</item>

            <item name="label" xsi:type="string" translate="true">Status</item>

        </item>

    </argument>

 </column>


Create a Status.php in Model -  Vendor_Name\Module_Name\Model\Status


<?php

namespace Mageget\WebPushNotification\Model;

use Magento\Framework\Data\OptionSourceInterface;

class Status implements OptionSourceInterface {

    public function getOptionArray() {

        $options = ["1" => __("Active"), "0" => __("Inactive") ];

        return $options;

    }

    public function getAllOptions() {

        $res = $this->getOptions();

        array_unshift($res, ["value" => "", "label" => ""]);

        return $res;

    }

    public function getOptions() {

        $res = [];

        foreach ($this->getOptionArray() as $index => $value) {

            $res[] = ["value" => $index, "label" => $value];

        }

        return $res;

    }

    public function toOptionArray() {

        return $this->getOptions();

    }

}








Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post