Skip to content

Cannot add new columns to item grid in admin sales_order_view layout #10824

Closed
@theodorhanu

Description

@theodorhanu

I am trying to add a new column to item grid in admin sales/order/view .
The problem is that in the layout the default renderer does not have a name attribute, only the as attribute, thus not allowing to add new column content. Even though I can add new column headers to the layout, using <referenceBlock name="order_items"> directive, I cannot add the column's content using the same aproach.

Preconditions

  1. Magento 2.1.x

Steps to reproduce

  1. Create sales_order_view.xml in custom module's adminhtml layouts folder
  2. Add a column in order_items arguments:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="order_items">
            <arguments>
                <argument name="columns" xsi:type="array">
                    <item name="test_column" xsi:type="string" translate="true">Test Header</item>
                </argument>
            </arguments>
            <block class="Namespace\Vendor\Block\Adminhtml\Order\Items\Column\TestColumn" name="column_production_id" template="Namespace_Vendor::order/items/column/test_column.phtml" group="column" />
        </referenceBlock>
    </body>
</page>

Expected result

  1. Column content should be displayed according to test_column.phtml

Actual result

  1. Only column headers are added

There should be posibility to add cell renderer using <referenceBlock name="default"> directive, like column addition.
The only solution I find is adding an afterGetColumns plugin to Magento\Sales\Block\Adminhtml\Order\View\Items\Renderer\DefaultRenderer, solutions which does not seem so elegant to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in 2.2.xThe issue has been fixed in 2.2 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions