开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 868|回复: 0

asp.net core 控件使用aside侧边栏和tabpanel右侧面板的问题

[复制链接]

0

精华

10

贡献

69

赞扬

帖子
8
软币
165
在线时间
9 小时
注册时间
2023-2-26
发表于 2023-9-11 12:09:46 | 显示全部楼层 |阅读模式
官方给的模板都是左侧导航菜单点击后,就路由到新的页面,这样很不方便,所以在下想实现的是,左侧点击,右侧会新建一个tab。tabpage之间可以进行切换。

初步思路是绑定数据,然后新建时通过post路由后台获取html,html渲染无异常
现在有个问题是,JavaScript代码无法使用
比如我点击新建菜单,然后会生成一个tabpage,这个tabpage是通过jQuery post方法获取  ~/menus/index的内容,
~/menus/index对应的cshtml的代码如下:
[C#] 纯文本查看 复制代码
@using DevExtreme.AspNet.Mvc;

@{
    ViewData["Title"] = "菜单管理";
}
<div id="tree-list-menus">
    <div>@ViewData["Title"]</div>
    @(Html.DevExtreme().TreeList<XCERPNetCore.Models.Menus>()
        .ID("employees")
        .DataSource(ds => ds.Mvc()
            .Controller("TreeListEmployees")
            .LoadAction("Get")
            .UpdateAction("Put")
            .InsertAction("Post")
            .DeleteAction("Delete")
            .Key("ID")
        )
        .KeyExpr("ID")
        .ParentIdExpr("HeadID")
        .ShowRowLines(true)
        .ShowBorders(true)
        .Editing(editing => editing
            .Mode(GridEditMode.Form)
            .AllowUpdating(true)
            .AllowDeleting(new JS("MenusTreeList_AllowDeleting"))
            .AllowAdding(true)
        )
        .Columns(columns =>
        {
            columns.AddFor(m => m.Id);
    
            columns.AddFor(m => m.Name);
    
            columns.AddFor(m => m.SortInt);
    
            columns.AddFor(m => m.Path);
    
            columns.AddFor(m => m.Icon);
    
            columns.AddFor(m => m.Path)
                .Width(150);
    
            columns.Add()
                .Type(TreeListCommandColumnType.Buttons)
                .Buttons(b =>
                {
                    b.Add().Name(TreeListColumnButtonName.Edit);
                    b.Add().Name(TreeListColumnButtonName.Delete);
                });
        })
        .ColumnAutoWidth(true)
        .OnEditorPreparing("MenusTreeList_onEditorPreparing")
        .OnInitNewRow("MenusTreeList_onInitNewRow")
        .ColumnChooser(cc =>
        {
            cc
                .Enabled(true)
                .Mode(GridColumnChooserMode.Select)
                .Position(pc => pc
                    .My(HorizontalAlignment.Right, VerticalAlignment.Top)
                    .At(HorizontalAlignment.Right, VerticalAlignment.Bottom)
                    .Of(".dx-treelist-column-chooser-button")
                );
    
            cc.Search(ccs => ccs
                .Enabled(true)
                .EditorOptions(new { Placeholder = "Search column" })
                );
    
            cc.Selection(ccs => ccs
                .AllowSelectAll(true)
                .SelectByClick(true)
                .Recursive(true)
                );
        })
        .ExpandedRowKeys(new[] { 1, 2, 3, 4, 5 })
        )

    <script type="text/javascript">
        function MenusTreeList_onEditorPreparing(e) {
            if (e.dataField === "HeadID" && e.row.data.ID === 1) {
                e.editorOptions.disabled = true;
                e.editorOptions.value = null;
            }
        }

        function MenusTreeList_onInitNewRow(e) {
            e.data.HeadID = 1;
        }

        function MenusTreeList_AllowDeleting(e) {
            return e.row.data.ID !== 1;
        }
    </script>
   
</div>


post过程通过f12开发者工具调试发现会报错,报错信息是MenusTreeList_AllowDeleting对象找不到。
这个怎么办?求大佬帮助,感谢
回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-29 07:10

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表