dcat-admin icon indicating copy to clipboard operation
dcat-admin copied to clipboard

模态窗 (Modal)中嵌入数据表格(grid)行内编辑后无效

Open e282486518 opened this issue 9 months ago • 1 comments

如题: 解决方法可以使用 $grid->setResource('/xxxx'); 重新设置修改URL

不过我又在modal中开启了导出功能 $grid->export(); 导致了两者冲突~~~~

重设url后导出功能错误, 删除重设url后行内编辑无效

e282486518 avatar Mar 25 '25 03:03 e282486518

已解决,使用如下代码重置html的某些属性

class ForumUserTable extends LazyRenderable
{
    public function grid(): Grid
    {
        $this->script();
        $this->scriptReUrl();
        $this->css();

        return Grid::make(new MeetingJoin(), function (Grid $grid) {
            // xxxxxx
            $grid->column('status', '审核')->radio([1=>'通过', '0'=>'审核中', -1 => '不通过']);
            $grid->export();
        });
    }

    // 在 modal中 dropdown-toggle 无效的临时解决方案
    protected function script()
    {
        $script = <<<JS
(function () {
    $(".dropdown-toggle").on('click',function(){
        $(this).next().toggleClass('show');
    })
})();
JS;
        Admin::script($script);
    }

    // 弹出框被modal覆盖了
    protected function css(){
        $css = <<<CSS
.popover {z-index: 9999;}
CSS;
        Admin::style($css);
    }

    // js重新设置"行内编辑"的url
    protected function scriptReUrl()
    {
        $script = <<<JS
(function () {
    $('.ie-wrap a').each(function(index, domEle){
        let id =  $(domEle).attr('data-key');
        let testurl = '/admin/join/' + id
        $(domEle).attr('data-url', testurl);
    });
})();
JS;
        Admin::script($script);
    }
class JoinController extends AdminController
{

    /**
     * 接收静态框中的行内编辑中传入的信息
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new MeetingJoin(), function (Form $form) {
            $form->display('id');
            $form->text('status');
        });
    }
}

e282486518 avatar Mar 25 '25 07:03 e282486518

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Sep 25 '25 04:09 stale[bot]