管理面板中“操作”列中的“编辑”选项不可见。如何解决这个问题?

时间:2019-07-12 07:36:20

标签: magento2

在创建管理网格时,操作列保持为空,并且“编辑”选项不可见。如何解决这个问题。

这是我的Ui_Component文件(操作部分)

<actionsColumn name="action" 
 class="Naiwrita\Boral\Ui\Component\Listing\Column\Action">
           <argument name="data" xsi:type="array">
               <item name="config" xsi:type="array">
                   <item name="resizeEnabled" xsi:type="boolean">true</item>
                   <item name="resizeDefaultWidth" xsi:type="string">107</item>
                   <item name="indexField" xsi:type="string">id</item>
               </item>
           </argument>
       </actionsColumn>

这是在其中实现了编辑选项的action.php文件

class Action extends Column
{
    const ROW_EDIT_URL = 'sample/index/addrow';
    protected $_urlBuilder;
    private $_editUrl;
    public function __construct(
        ContextInterface $context,
        UiComponentFactory $uiComponentFactory,
        UrlInterface $urlBuilder,
        array $components = [],
        array $data = [],
        $editUrl = self::ROW_EDIT_URL) 
    {
        $this->_urlBuilder = $urlBuilder;
        $this->_editUrl = $editUrl;
        parent::__construct($context, $uiComponentFactory, $components, $data);
    }
    public function prepareDataSource(array $dataSource)
    {
        if (isset($dataSource['data']['items'])) {
            foreach ($dataSource['data']['items'] as &$item) {
                $name = $this->getData('name');
                if (isset($item['id'])) {
                   $item[$name]['edit'] = [
                        'href' => $this->_urlBuilder->getUrl($this->_editUrl,  ['id' => $item['id']]),
                        'label' => __('Edit'),
                    ];
                }
            }
        }return $dataSource;
    }
}

0 个答案:

没有答案