1

In Magento 2.2.5, I am sending the id in the url now, But, I want send multiple parameters in the admin grid action url. I created admin grid using layout Blocks. Not used ui component.

How to achieve this.

Here is my code:

<block class="Magento\Backend\Block\Widget\Grid\Column" as="action">
                    <arguments>
                        <argument name="id" xsi:type="string">action</argument>
                        <argument name="header" xsi:type="string" translate="true">Action</argument>
                        <argument name="type" xsi:type="string">action</argument>
                        <argument name="getter" xsi:type="string">getId</argument>
                        <argument name="filter" xsi:type="boolean">false</argument>
                        <argument name="sortable" xsi:type="boolean">false</argument>
                        <argument name="index" xsi:type="string">weblog</argument>
                        <argument name="is_system" xsi:type="boolean">true</argument>
                        <argument name="actions" xsi:type="array">
                            <item name="view_action" xsi:type="array">
                                <item name="caption" xsi:type="string" translate="true">Assign</item>
                                <item name="url" xsi:type="array">
                                    <item name="base" xsi:type="string">apptha_customergroup/deal/assign</item>
                                </item>
                                <item name="field" xsi:type="string">id</item>
                            </item>
                        </argument>
                        <argument name="header_css_class" xsi:type="string">col-actions</argument>
                        <argument name="column_css_class" xsi:type="string">col-actions</argument>
                    </arguments>
                </block>
3
  • dose you have any solution found that? Commented Jan 3, 2019 at 12:12
  • @PrashantPatel, Yes. I'll update my answer now. Commented Jan 3, 2019 at 12:16
  • Please let me know is this solution solved your issue. Commented Jan 3, 2019 at 12:23

1 Answer 1

1

I used Renderer to achieve this.

Please find my code here.

Layout File:

<block class="Magento\Backend\Block\Widget\Grid\Column" as="action">
                    <arguments>
                        <argument name="id" xsi:type="string">action</argument>
                        <argument name="header" xsi:type="string" translate="true">Action</argument>
                        <argument name="type" xsi:type="string">action</argument>
                        <argument name="getter" xsi:type="string">getId</argument>
                        <argument name="filter" xsi:type="boolean">false</argument>
                        <argument name="sortable" xsi:type="boolean">false</argument>
                        <argument name="index" xsi:type="string">entity_id</argument>
                        <argument name="is_system" xsi:type="boolean">true</argument>
                        <argument name="renderer" xsi:type="string">Apptha\Deal\Block\Adminhtml\Deal\Grid\Column\Renderer\Assignaction</argument>
                        <argument name="header_css_class" xsi:type="string">col-actions</argument>
                        <argument name="column_css_class" xsi:type="string">col-actions</argument>
                    </arguments>
                </block>

Block file (Apptha\Deal\Block\Adminhtml\Deal\Grid\Column\Renderer\Assignaction.php):

<?php
namespace Apptha\Deal\Block\Adminhtml\Deal\Grid\Column\Renderer;
use \Magento\Framework\View\Element\Template;
use \Magento\Framework\View\Element\Template\Context;
use \Magento\Store\Model\StoreManagerInterface;
use \Apptha\Deal\Helper\Data;

class Assignaction extends \Magento\Backend\Block\Widget\Grid\Column\Renderer\Text
{

    protected $_helper;
    protected $urlBuilder;

    public function __construct(\Magento\Framework\UrlInterface $urlBuilder) 
    {
        $this->urlBuilder = $urlBuilder;
    }

    public function render(\Magento\Framework\DataObject $row)
    {
        /** @var \Magento\Integration\Model\Integration $row */
        $merchantId = $row->getData("merchant_id");
        $manageDealId = $row->getData("entity_id");
        $actionUrl = $this->urlBuilder->getUrl("deals/deal/responsedetails/id/$manageDealId/mid/$merchantId" );
        return "<a href=".$actionUrl.">Details</a>";
    }
}
3
  • this way is fine but I want to pass data without URL is that possible? Commented Jan 3, 2019 at 12:22
  • Try in registry method. Commented Jan 3, 2019 at 12:26
  • Add Upvote if it is useful. Commented Jan 3, 2019 at 12:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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