首页 > 解决方案 > 下载、打开和删除文件按钮不可见

问题描述

我正在尝试在 Asp.Net 和 Javascript 中修复一个网页,该网页允许用户上传文件,然后让他有机会下载或打开附件。

在 cshtml 文件中有一个 Javascript 函数,其结构如下:

DT.load("appointment-course-files").then(c => {
            c.buildDom = function (table, wrapper) {
                let titleBlock = document.createElement("div");
                titleBlock.classList.add("clearfix", "m-b-1");
                let title = document.createElement("h5");
                title.classList.add("pull-xs-left");
                title.textContent = "Files";
                titleBlock.appendChild(title);
                let clearfix = document.createElement("clearfix");
                clearfix.classList.add("clearfix");
                clearfix.appendChild(table);
                wrapper.element.appendChild(titleBlock);
                wrapper.element.appendChild(clearfix);
            };
            c.actions.add()
                .style(ActionStyle.btn("black btn-round", "fas fa-search", "Apri"))
                .open("/api/appointmentcourse/{AppCourseId}/files/{Id}?open=true");
            c.actions.add()
                .style(ActionStyle.btn("info btn-round", "fas fa-cloud-download-alt", "Download"))
                .redirect("/api/appointmentcourse/{AppCourseId}/files/{Id}?open=false");
            c.actions.add()
                .style(ActionStyle.btn("danger btn-round", "fas fa-trash", "Elimina"))
                .withConfirmation("Si sicuro di voler eliminare il file '{Filename}'?")
                .ajax("DELETE", "/api/appointmentcourse/{AppCourseId}/files/{Id}");
        });

相反,这是连接到 Javascript 的 DataTable 类:

public void BuildTables(IDataTableShelf shelf)
    {
        var u = SafePlusModels.Models.User.Empty;
        var builder =
        shelf.DefineTable<DTCourseAppointmentFile, AppointmentCourseFile>("appointment-course-files")
            .SetPk(action => action.Id)
            .AddColumn(action => action.Id).Hide().Done(AppointmentCourseFile.Empty.Id)
            .AddColumn(action => action.Filename).SetTitle("Name").Done(AppointmentCourseFile.Empty.FileName)
            .AddColumn(action => action.Uploader)
            .SetTitle("Uploader").Done(u.Username)
            .AddColumn(action => action.TimeStamp).SetTitle("Date").Done(AppointmentCourseFile.Empty.TimeStamp)
            .AddColumn(action => action.AppCourseId).Hide().Done(AppointmentCourseFile.Empty.AppointmentCourse);
        builder.Configuration.Columns.Write(cols =>
            {
                cols[nameof(Filename)].Configuration.LikeConditionScope = LikeConditionScope.Around;
            });
        builder.References
            .Add(SafePlusModels.Models.User.GetTable(), new WhereStatementBuilder
            {
                {AppointmentCourseFile.Empty.Uploader, Operator.Equals, u.Id}
            });
    }

我用一系列断点调试了代码,但我看不出问题出在哪里。这对我来说似乎是正确的,但在某种程度上我不知道我看不到下载、打开和删除附加文档的按钮。有什么建议么?

标签: javascriptasp.net

解决方案


推荐阅读