分类
Magento

magento2 ui Component button 如何传值

listing.xml

<listing>
    <settings>
        <buttons>
            <button name="add" class="Maijindou\Enquire\Block\Adminhtml\EnquireItem\Edit\AddButton"/>
        </buttons>
    </settings>
</listing>

\Maijindou\Enquire\Block\Adminhtml\EnquireItem\Edit\AddButton

    /**
     * @return array
     */
    public function getButtonData()
    {
        $data = [
            'label' => __('Add new Buyback Exchange Item'),
            'class' => 'primary',
            'on_click' => 'deleteConfirm(\'' . __(
                'Are you sure you want to do this?'
            ) . '\', \'' . $this->getDeleteUrl() . '\')',
            'sort_order' => 20,
        ];
        return $data;
    }

    /**
     * Get URL for delete button
     *
     * @return string
     */
    public function getDeleteUrl()
    {
        return $this->getUrl('*/*/new', ['enquire_id' => $this->getId()]);
    }