Remove column from Order grid based on condition

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
4
down vote

favorite












I want to remove status column from Magento admin panel order grid.



I use below code to remove the status column in my sales_order_grid.xml file. Reference



<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_columns">
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="componentDisabled" xsi:type="boolean">true</item>
</item>
</argument>
</column>
</columns>
</listing>


It removes status column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration section.



Is there any way I can add a condition on componentDisabled, or any other way to achieve my requirements?










share|improve this question



























    up vote
    4
    down vote

    favorite












    I want to remove status column from Magento admin panel order grid.



    I use below code to remove the status column in my sales_order_grid.xml file. Reference



    <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="sales_order_columns">
    <column name="status">
    <argument name="data" xsi:type="array">
    <item name="config" xsi:type="array">
    <item name="componentDisabled" xsi:type="boolean">true</item>
    </item>
    </argument>
    </column>
    </columns>
    </listing>


    It removes status column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration section.



    Is there any way I can add a condition on componentDisabled, or any other way to achieve my requirements?










    share|improve this question























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I want to remove status column from Magento admin panel order grid.



      I use below code to remove the status column in my sales_order_grid.xml file. Reference



      <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
      <columns name="sales_order_columns">
      <column name="status">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="componentDisabled" xsi:type="boolean">true</item>
      </item>
      </argument>
      </column>
      </columns>
      </listing>


      It removes status column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration section.



      Is there any way I can add a condition on componentDisabled, or any other way to achieve my requirements?










      share|improve this question













      I want to remove status column from Magento admin panel order grid.



      I use below code to remove the status column in my sales_order_grid.xml file. Reference



      <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
      <columns name="sales_order_columns">
      <column name="status">
      <argument name="data" xsi:type="array">
      <item name="config" xsi:type="array">
      <item name="componentDisabled" xsi:type="boolean">true</item>
      </item>
      </argument>
      </column>
      </columns>
      </listing>


      It removes status column successfully but I want to remove it based on a condition, value of a configuration field from Stores > Configuration section.



      Is there any way I can add a condition on componentDisabled, or any other way to achieve my requirements?







      magento2 grid column






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 1 hour ago









      Jaimin Sutariya

      9,05121751




      9,05121751




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          It Might be helpful to you.



          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <columns name="sales_order_columns">
          <column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
          <settings>
          <addField>true</addField>
          <options class="MagentoStoreModelResourceModelWebsiteCollection"/>
          <dataType>text</dataType>
          <label translate="true">Websites</label>
          </settings>
          </column>
          </columns>
          </listing>


          Websites.php



          <?php
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUiComponentListingColumns;

          use MagentoFrameworkViewElementUiComponentFactory;
          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoStoreModelStoreManagerInterface;

          /**
          * @api
          * @since 100.0.2
          */
          class Websites extends MagentoUiComponentListingColumnsColumn

          /**
          * Column name
          */
          const NAME = 'websites';

          /**
          * Store manager
          *
          * @var StoreManagerInterface
          */
          protected $storeManager;

          /**
          * @param ContextInterface $context
          * @param UiComponentFactory $uiComponentFactory
          * @param StoreManagerInterface $storeManager
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UiComponentFactory $uiComponentFactory,
          StoreManagerInterface $storeManager,
          array $components = ,
          array $data =
          )
          parent::__construct($context, $uiComponentFactory, $components, $data);
          $this->storeManager = $storeManager;


          /**
          * @inheritdoc
          * @deprecated 101.0.0
          */
          public function prepareDataSource(array $dataSource)

          $websiteNames = ;
          foreach ($this->getData('options') as $website)
          $websiteNames[$website->getWebsiteId()] = $website->getName();

          if (isset($dataSource['data']['items']))
          $fieldName = $this->getData('name');
          foreach ($dataSource['data']['items'] as & $item)
          $websites = ;
          foreach ($item[$fieldName] as $websiteId)
          if (!isset($websiteNames[$websiteId]))
          continue;

          $websites = $websiteNames[$websiteId];

          $item[$fieldName] = implode(', ', $websites);



          return $dataSource;


          /**
          * Prepare component configuration
          * @return void
          */
          public function prepare()

          parent::prepare();
          if ($this->storeManager->isSingleStoreMode())
          $this->_data['config']['componentDisabled'] = true;





          It's defualt Magento which is used for to display website based on condition.






          share|improve this answer




















          • Thanks Dharmendra for the answer. I will try to implement it with my code.
            – Jaimin Sutariya
            1 hour ago










          • Welcome bro anytime.
            – Dharmendra Jadav
            1 hour ago










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f242687%2fremove-column-from-order-grid-based-on-condition%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote



          accepted










          It Might be helpful to you.



          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <columns name="sales_order_columns">
          <column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
          <settings>
          <addField>true</addField>
          <options class="MagentoStoreModelResourceModelWebsiteCollection"/>
          <dataType>text</dataType>
          <label translate="true">Websites</label>
          </settings>
          </column>
          </columns>
          </listing>


          Websites.php



          <?php
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUiComponentListingColumns;

          use MagentoFrameworkViewElementUiComponentFactory;
          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoStoreModelStoreManagerInterface;

          /**
          * @api
          * @since 100.0.2
          */
          class Websites extends MagentoUiComponentListingColumnsColumn

          /**
          * Column name
          */
          const NAME = 'websites';

          /**
          * Store manager
          *
          * @var StoreManagerInterface
          */
          protected $storeManager;

          /**
          * @param ContextInterface $context
          * @param UiComponentFactory $uiComponentFactory
          * @param StoreManagerInterface $storeManager
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UiComponentFactory $uiComponentFactory,
          StoreManagerInterface $storeManager,
          array $components = ,
          array $data =
          )
          parent::__construct($context, $uiComponentFactory, $components, $data);
          $this->storeManager = $storeManager;


          /**
          * @inheritdoc
          * @deprecated 101.0.0
          */
          public function prepareDataSource(array $dataSource)

          $websiteNames = ;
          foreach ($this->getData('options') as $website)
          $websiteNames[$website->getWebsiteId()] = $website->getName();

          if (isset($dataSource['data']['items']))
          $fieldName = $this->getData('name');
          foreach ($dataSource['data']['items'] as & $item)
          $websites = ;
          foreach ($item[$fieldName] as $websiteId)
          if (!isset($websiteNames[$websiteId]))
          continue;

          $websites = $websiteNames[$websiteId];

          $item[$fieldName] = implode(', ', $websites);



          return $dataSource;


          /**
          * Prepare component configuration
          * @return void
          */
          public function prepare()

          parent::prepare();
          if ($this->storeManager->isSingleStoreMode())
          $this->_data['config']['componentDisabled'] = true;





          It's defualt Magento which is used for to display website based on condition.






          share|improve this answer




















          • Thanks Dharmendra for the answer. I will try to implement it with my code.
            – Jaimin Sutariya
            1 hour ago










          • Welcome bro anytime.
            – Dharmendra Jadav
            1 hour ago














          up vote
          3
          down vote



          accepted










          It Might be helpful to you.



          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <columns name="sales_order_columns">
          <column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
          <settings>
          <addField>true</addField>
          <options class="MagentoStoreModelResourceModelWebsiteCollection"/>
          <dataType>text</dataType>
          <label translate="true">Websites</label>
          </settings>
          </column>
          </columns>
          </listing>


          Websites.php



          <?php
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUiComponentListingColumns;

          use MagentoFrameworkViewElementUiComponentFactory;
          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoStoreModelStoreManagerInterface;

          /**
          * @api
          * @since 100.0.2
          */
          class Websites extends MagentoUiComponentListingColumnsColumn

          /**
          * Column name
          */
          const NAME = 'websites';

          /**
          * Store manager
          *
          * @var StoreManagerInterface
          */
          protected $storeManager;

          /**
          * @param ContextInterface $context
          * @param UiComponentFactory $uiComponentFactory
          * @param StoreManagerInterface $storeManager
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UiComponentFactory $uiComponentFactory,
          StoreManagerInterface $storeManager,
          array $components = ,
          array $data =
          )
          parent::__construct($context, $uiComponentFactory, $components, $data);
          $this->storeManager = $storeManager;


          /**
          * @inheritdoc
          * @deprecated 101.0.0
          */
          public function prepareDataSource(array $dataSource)

          $websiteNames = ;
          foreach ($this->getData('options') as $website)
          $websiteNames[$website->getWebsiteId()] = $website->getName();

          if (isset($dataSource['data']['items']))
          $fieldName = $this->getData('name');
          foreach ($dataSource['data']['items'] as & $item)
          $websites = ;
          foreach ($item[$fieldName] as $websiteId)
          if (!isset($websiteNames[$websiteId]))
          continue;

          $websites = $websiteNames[$websiteId];

          $item[$fieldName] = implode(', ', $websites);



          return $dataSource;


          /**
          * Prepare component configuration
          * @return void
          */
          public function prepare()

          parent::prepare();
          if ($this->storeManager->isSingleStoreMode())
          $this->_data['config']['componentDisabled'] = true;





          It's defualt Magento which is used for to display website based on condition.






          share|improve this answer




















          • Thanks Dharmendra for the answer. I will try to implement it with my code.
            – Jaimin Sutariya
            1 hour ago










          • Welcome bro anytime.
            – Dharmendra Jadav
            1 hour ago












          up vote
          3
          down vote



          accepted







          up vote
          3
          down vote



          accepted






          It Might be helpful to you.



          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <columns name="sales_order_columns">
          <column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
          <settings>
          <addField>true</addField>
          <options class="MagentoStoreModelResourceModelWebsiteCollection"/>
          <dataType>text</dataType>
          <label translate="true">Websites</label>
          </settings>
          </column>
          </columns>
          </listing>


          Websites.php



          <?php
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUiComponentListingColumns;

          use MagentoFrameworkViewElementUiComponentFactory;
          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoStoreModelStoreManagerInterface;

          /**
          * @api
          * @since 100.0.2
          */
          class Websites extends MagentoUiComponentListingColumnsColumn

          /**
          * Column name
          */
          const NAME = 'websites';

          /**
          * Store manager
          *
          * @var StoreManagerInterface
          */
          protected $storeManager;

          /**
          * @param ContextInterface $context
          * @param UiComponentFactory $uiComponentFactory
          * @param StoreManagerInterface $storeManager
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UiComponentFactory $uiComponentFactory,
          StoreManagerInterface $storeManager,
          array $components = ,
          array $data =
          )
          parent::__construct($context, $uiComponentFactory, $components, $data);
          $this->storeManager = $storeManager;


          /**
          * @inheritdoc
          * @deprecated 101.0.0
          */
          public function prepareDataSource(array $dataSource)

          $websiteNames = ;
          foreach ($this->getData('options') as $website)
          $websiteNames[$website->getWebsiteId()] = $website->getName();

          if (isset($dataSource['data']['items']))
          $fieldName = $this->getData('name');
          foreach ($dataSource['data']['items'] as & $item)
          $websites = ;
          foreach ($item[$fieldName] as $websiteId)
          if (!isset($websiteNames[$websiteId]))
          continue;

          $websites = $websiteNames[$websiteId];

          $item[$fieldName] = implode(', ', $websites);



          return $dataSource;


          /**
          * Prepare component configuration
          * @return void
          */
          public function prepare()

          parent::prepare();
          if ($this->storeManager->isSingleStoreMode())
          $this->_data['config']['componentDisabled'] = true;





          It's defualt Magento which is used for to display website based on condition.






          share|improve this answer












          It Might be helpful to you.



          <listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
          <columns name="sales_order_columns">
          <column name="websites" class="MagentoCatalogUiComponentListingColumnsWebsites" sortOrder="100">
          <settings>
          <addField>true</addField>
          <options class="MagentoStoreModelResourceModelWebsiteCollection"/>
          <dataType>text</dataType>
          <label translate="true">Websites</label>
          </settings>
          </column>
          </columns>
          </listing>


          Websites.php



          <?php
          /**
          * Copyright © Magento, Inc. All rights reserved.
          * See COPYING.txt for license details.
          */
          namespace MagentoCatalogUiComponentListingColumns;

          use MagentoFrameworkViewElementUiComponentFactory;
          use MagentoFrameworkViewElementUiComponentContextInterface;
          use MagentoStoreModelStoreManagerInterface;

          /**
          * @api
          * @since 100.0.2
          */
          class Websites extends MagentoUiComponentListingColumnsColumn

          /**
          * Column name
          */
          const NAME = 'websites';

          /**
          * Store manager
          *
          * @var StoreManagerInterface
          */
          protected $storeManager;

          /**
          * @param ContextInterface $context
          * @param UiComponentFactory $uiComponentFactory
          * @param StoreManagerInterface $storeManager
          * @param array $components
          * @param array $data
          */
          public function __construct(
          ContextInterface $context,
          UiComponentFactory $uiComponentFactory,
          StoreManagerInterface $storeManager,
          array $components = ,
          array $data =
          )
          parent::__construct($context, $uiComponentFactory, $components, $data);
          $this->storeManager = $storeManager;


          /**
          * @inheritdoc
          * @deprecated 101.0.0
          */
          public function prepareDataSource(array $dataSource)

          $websiteNames = ;
          foreach ($this->getData('options') as $website)
          $websiteNames[$website->getWebsiteId()] = $website->getName();

          if (isset($dataSource['data']['items']))
          $fieldName = $this->getData('name');
          foreach ($dataSource['data']['items'] as & $item)
          $websites = ;
          foreach ($item[$fieldName] as $websiteId)
          if (!isset($websiteNames[$websiteId]))
          continue;

          $websites = $websiteNames[$websiteId];

          $item[$fieldName] = implode(', ', $websites);



          return $dataSource;


          /**
          * Prepare component configuration
          * @return void
          */
          public function prepare()

          parent::prepare();
          if ($this->storeManager->isSingleStoreMode())
          $this->_data['config']['componentDisabled'] = true;





          It's defualt Magento which is used for to display website based on condition.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 1 hour ago









          Dharmendra Jadav

          1,258218




          1,258218











          • Thanks Dharmendra for the answer. I will try to implement it with my code.
            – Jaimin Sutariya
            1 hour ago










          • Welcome bro anytime.
            – Dharmendra Jadav
            1 hour ago
















          • Thanks Dharmendra for the answer. I will try to implement it with my code.
            – Jaimin Sutariya
            1 hour ago










          • Welcome bro anytime.
            – Dharmendra Jadav
            1 hour ago















          Thanks Dharmendra for the answer. I will try to implement it with my code.
          – Jaimin Sutariya
          1 hour ago




          Thanks Dharmendra for the answer. I will try to implement it with my code.
          – Jaimin Sutariya
          1 hour ago












          Welcome bro anytime.
          – Dharmendra Jadav
          1 hour ago




          Welcome bro anytime.
          – Dharmendra Jadav
          1 hour ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f242687%2fremove-column-from-order-grid-based-on-condition%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          What does second last employer means? [closed]

          List of Gilmore Girls characters

          One-line joke