我创建了一个网格,我想在Magento2的这个网格中添加一个链接,例如:查看,添加订单ID上的链接等。
控制器: Inchoo / Helloworld / Controller / Index / Index.php
型号: Inchoo / Helloworld / Model / Orderprocessing.php
ResourceModel: Inchoo / Helloworld / Model / ResourceModel / Orderprocessing.php
收藏: Inchoo / Helloworld / Model / ResourceModel / Orderprocessing / Collection.php
布局: Inchoo / Helloworld / view / adminhtml / layout / helloworld_orderprocessing_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<!--<uiComponent name="inchoo_orderprocessing_grid"/>-->
<block class="Inchoo\Helloworld\Block\Adminhtml\Orderprocessing" name="inchoo_orderprocessing_grid">
<block class="Magento\Backend\Block\Widget\Grid" name="inchoo_orderprocessing_grid.grid" as="grid">
<arguments>
<argument name="id" xsi:type="string">orderprocessing_id</argument>
<argument name="dataSource" xsi:type="object">Inchoo\Helloworld\Model\ResourceModel\Orderprocessing\Collection</argument>
<argument name="default_sort" xsi:type="string">entity_id</argument>
<argument name="default_dir" xsi:type="string">ASC</argument>
<argument name="save_parameters_in_session" xsi:type="string">1</argument>
</arguments>
<block class="Magento\Backend\Block\Widget\Grid\ColumnSet" name="inchoo_orderprocessing_grid.grid.columnSet" as="grid.columnSet">
<block class="Magento\Backend\Block\Widget\Grid\Column" as="increment_id">
<arguments>
<argument name="header" xsi:type="string" translate="true">Order id</argument>
<argument name="index" xsi:type="string">increment_id</argument>
<argument name="type" xsi:type="string">text</argument>
<argument name="column_css_class" xsi:type="string">col-id</argument>
<argument name="header_css_class" xsi:type="string">col-id</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="shipment_id">
<arguments>
<argument name="header" xsi:type="string" translate="true">Shipment id</argument>
<argument name="index" xsi:type="string">shipment_id</argument>
<argument name="type" xsi:type="string">text</argument>
<argument name="column_css_class" xsi:type="string">col-id</argument>
<argument name="header_css_class" xsi:type="string">col-id</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="tracking_number">
<arguments>
<argument name="header" xsi:type="string" translate="true">Tracking Number</argument>
<argument name="index" xsi:type="string">tracking_number</argument>
<argument name="type" xsi:type="string">text</argument>
<argument name="column_css_class" xsi:type="string">col-id</argument>
<argument name="header_css_class" xsi:type="string">col-id</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="created_at">
<arguments>
<argument name="header" xsi:type="string" translate="true">Created Time</argument>
<argument name="index" xsi:type="string">created_at</argument>
<argument name="type" xsi:type="string">date</argument>
<argument name="column_css_class" xsi:type="string">col-id</argument>
<argument name="header_css_class" xsi:type="string">col-id</argument>
</arguments>
</block>
</block>
</block>
</block>
</referenceContainer>
</body>
</page>
答案 0 :(得分:0)
平均自定义网格操作?请检查此http://www.ibnab.com/en/blog/magento-2/magento-2-backend-add-custom-grid-action-target-_self-or-_blank
顺便说一下,您是否有任何想法将追踪号码添加到销售订单网格?