0

I have created custom module and show product data in grid structure using Xml in layout folder. But for dropdown attribute its show value instead of its label. How to show dropdown attribute label using xml

<block class="module\vendorname\Block\Vendors\Widget\Grid\Column" as="unit">
                  <arguments>
                      <argument name="header" xsi:type="string" translate="true">Units</argument>
                      <argument name="sortable" xsi:type="string">0</argument>
                      <argument name="index" xsi:type="string">unit</argument>
                      <argument name="header_css_class" xsi:type="string">col-units</argument>
                      <argument name="column_css_class" xsi:type="string">col-units</argument>
                  </arguments>
          </block>
1

You can try following way (UI Component):

<column name="page_layout" component="Magento_Ui/js/grid/columns/select">
        <settings>
            <options class="Magento\Cms\Model\Page\Source\PageLayout"/>
            <filter>select</filter>
            <editor>
                <editorType>select</editorType>
            </editor>
            <dataType>select</dataType>
            <label translate="true">Layout</label>
        </settings>
    </column>

Check detail CMS module

[Update]

Without UI component:

$this->addColumn(
        'is_active',
        [
            'header' => __('Status'),
            'index' => 'is_active',
            'type' => 'options',
            'options' => $this->_cmsPage->getAvailableStatuses()
        ]
    );

Check here for detail

[Update]

Try another way:

<block class="Magento\Backend\Block\Widget\Grid\Column" name="integration.grid.columnSet.status" as="status">
    <arguments>
        <argument name="header" xsi:type="string" translate="true">Status</argument>
        <argument name="type" xsi:type="string">options</argument>
        <argument name="options" xsi:type="options" model="Magento\Integration\Model\Integration\Source\Status"/>
        <argument name="index" xsi:type="string">status</argument>
        <argument name="id" xsi:type="string">status</argument>
    </arguments>
</block>

Check here for detail

  • I have create xml file in layout folder not in ui_component. – kim na na Feb 27 at 10:12
  • Check updated answer – Sohel Rana Feb 27 at 10:22
  • please check updated question – kim na na Feb 27 at 10:49
  • Check updated answer, try last one – Sohel Rana Feb 27 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.