magento2 - 获取 URL 参数并应用于 UI 组件中的按钮

标签 magento2

我正在尝试传递一个 URL 参数并将其应用于 adminhtml UI 组件中的一个按钮。下面是 UI 组件按钮的 XML。这已经是 1 层深了,我需要将作业的 ID 传递到我的 Controller Company\Module\Controller\Action\Stop,以便可以更新作业状态。将 URL 参数传递给 UI 组件是我面临的唯一障碍。

当前页面的URL:

http://project.dev/admin/mymodule/runjob/index/job_id/1/key/XXXXX/

需要将 job_id 值传递给下面的 UI 组件 ([X])。

<argument name="data" xsi:type="array">
    [...]
    <item name="buttons" xsi:type="array">
        <item name="stop_job" xsi:type="array">
            <item name="name" xsi:type="string">trigger</item>
            <item name="label" xsi:type="string" translate="true">Stop Job</item>
            <item name="class" xsi:type="string">primary</item>
            <item name="url" xsi:type="string">*/action/stop/job_id/[X]</item>
        </item>
    </item>
</argument>

有问题的按钮。

UI Component Button

最佳答案

您可以添加如下所示的按钮,

  <item name="buttons" xsi:type="array">
        <item name="add" xsi:type="string">Gratifi\Company\Block\Adminhtml\Runjob\AddButton</item>
    </item>  

并在该 block 中写入 getButtonData()。

关于magento2 - 获取 URL 参数并应用于 UI 组件中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45069577/

相关文章:

php - 按首选项覆盖 Magento_SalesRule ResourceModel 会引发错误 : Type Error occurred when creating object

magento2 - Magento 2.2.0 - 无法添加捆绑产品

Magento 2 安装语言包(nl_NL 翻译)

php - Magento 2 在管理员发票中添加额外费用

Magento 2.1.4,在管理面板>内容>设计>配置页面中,没有显示数据。我附上截图以供引用

php - Magento 2 自定义小部件设置模板数据未在前端呈现

css - 更改 Magento 2.0 主题中的 CSS

php - 如何以编程方式获取 Magento 2 模型中商店的根类别 ID

magento2 - 将售完的产品推至结果末尾

mysql - Magento 2.1.7订单保存错误: SQLSTATE[42S02]: