简体   繁体   English

MVC:发布后数据表不包含任何数据

[英]MVC: Datatable does not contain any data after publishing

I start by saying this is the first project I have ever published and apologize in advance if I give you too much or too little information.我首先说这是我发布的第一个项目,如果我提供的信息过多或过少,请提前道歉。 So, I published this MVC project to a business server.因此,我将此 MVC 项目发布到了业务服务器。 It works but the data in the datatable is not showing.它有效,但数据表中的数据未显示。 Although, when I just debug in Visual Studio there is data.虽然,当我只是在 Visual Studio 中调试时,有数据。 This project has 2 tabs:该项目有 2 个标签:
The first tab is to show the datatable in question which uses [u]Entity Framework[/u];第一个选项卡是显示有问题的数据表,它使用 [u]Entity Framework[/u];
The second tab also has a datatable(a yadcf) which shows data that is accessed via [u]Ado.Net[/u].第二个选项卡还有一个数据表(一个 yadcf),它显示通过 [u]Ado.Net[/u] 访问的数据。 Data in the first tab does not show, while it does in the second tab.第一个选项卡中的数据不显示,而第二个选项卡中的数据显示。

The datatable on the first tab references to this link:第一个选项卡上的数据表引用了此链接:

While for the second tab I imported the yadcf datatable.对于第二个选项卡,我导入了 yadcf 数据表。 Below is how I reference to it:下面是我如何引用它:

Also, when I do F12 under the "Elements" I can see the references to the datatables(see attached photo).另外,当我在“元素”下执行 F12 时,我可以看到对数据表的引用(见附图)。 Plus it looks like the datatable and its functionalities(search box, paging, column names) show up but without any data in it.此外,它看起来像数据表及其功能(搜索框、分页、列名)显示但没有任何数据。

没有数据的数据表

IN CASE YOU WANT TO SEE IT, THIS IS THE CODE OF THE INDEX PAGE WHICH INCLUDES THE DATATABLE:如果您想查看它,这是包含数据表的索引页面的代码:

@{
    ViewBag.Title = "Index";
}

<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#firstTab">View All</a></li>
    <li><a data-toggle="tab" href="#secondTab">Add New</a></li>
    <li><a data-toggle="tab" href="#thirdTab">Knowledge</a></li>
    <li><a data-toggle="tab" href="#fourthTab">IT Tasks</a></li>
</ul>

<div class="tab-content">
    <div id="firstTab" class="tab-pane fade in active">@Html.Action("ViewAll")</div>
    <div id="secondTab" class="tab-pane fade in">@Html.Action("AddOrEdit")</div>
    <div id="thirdTab" class="tab-pane fade in">@Html.Action("ViewAllKnowledge")</div>
    <div id="fourthTab" class="tab-pane fade in">@Html.Action("ViewAllTasks")</div>
</div>



@*jQuery Datatable CSS*@
<link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css">                                
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">                    
<link rel="stylesheet" href="https://cdn.datatables.net/colreorder/1.5.2/css/colReorder.dataTables.min.css">                    


@section scripts
{
    @Scripts.Render("~/bundles/jqueryval")

    @*jQuery Datatable JS*@
    <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js"></script>
    <script src="https://code.jquery.com/ui/1.12.0/jquery-ui.js"></script>
    <script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js"></script>                         
    <script src="https://cdn.datatables.net/colreorder/1.5.2/js/dataTables.colReorder.min.js"></script>                        

    <script>
        function activatejQueryTable() {

            var table = $('#ticketTable').DataTable({
                rowReorder: { selector: 'tr' }, 
                colReorder: true,              
                "stateSave": true,              
                "stateDuration": 0,             
                "autoWidth": false,             
                "columnDefs": [
                    { "width": "40px", "targets": 0, "visible": true },     
                    { "width": "150px", "targets": 1, "visible": true },    //dtLastUpdated
                    { "width": "250px", "targets": 2, "visible": true },    //vcSubject
                    { "width": "150px", "targets": 3, "visible": true },    //vcFrom
                    { "width": "53px", "targets": 4, "visible": true },     //vcPriority
                    { "width": "90px", "targets": 5, "visible": true },     //vcAssignedTo
                    { "width": "53px", "targets": 6, "visible": true },     //vcStatus
                    { "width": "90px", "targets": 7, "visible": true },     //vcRequestType
                    { "width": "90px", "targets": 8, "visible": true },     //vcLocation
                    { "width": "90px", "targets": 9, "visible": true },     //vcCategory
                    { "width": "90px", "targets": 10, "visible": true },    //dtAnticipatedCompletion
                    { "width": "100px", "targets": 11, "visible": true }     //edit and delete buttons
                ],

                //Create the dropdowns
                responsive: true,
                "bAutoWidth": false,            
                initComplete: function () {

                    this.api().columns([4, 5, 6, 7, 8, 9]).every(function () {      
                        var column = this;

                        var select = $('<select class="myDropdown"><option value=""></option></select>')

                            .appendTo($("#filters").find("th").eq(column.index()))
                            .on('change', function () {
                                var val = $.fn.dataTable.util.escapeRegex($(this).val());
                                column.search(val ? '^' + val + '$' : '', true, false).draw();
                            })
                            .on('click', function (e) {
                                e.stopPropagation();                                
                            });

                        column.data().unique().sort().each(function (d, j) {
                            $(select).append('<option value="' + d + '">' + d + '</option>')
                        });
                    });
                }
                //End of create dropdowns
            });

        }
        //});

        $(function () {
            activatejQueryTable();
        });

</script>
}

FYI, when I published I used the below:仅供参考,当我发布时,我使用了以下内容:

UNDER CONNECTION: Publish method: Web Deploy Server: (Business Server Name) Site name: HelpDeskSupport Username: myUsername Password: myPassoword连接下:发布方法:Web 部署服务器:(业务服务器名称)站点名称:HelpDeskSupport 用户名:myUsername 密码:myPassoword

UNDER SETTINGS: Under "DBModel" as the datasource I added the SQL Server name with its username and password. UNDER SETTINGS:在作为数据源的“DBModel”下,我添加了 SQL Server 名称及其用户名和密码。 I checked the "Use this connection string at runtime..."我检查了“在运行时使用此连接字符串...”

Could you please help me figure out what I have done wrong?你能帮我弄清楚我做错了什么吗? Thank you.谢谢你。

I found the solution.我找到了解决方案。 There was some permission code that I set up which was not allowing to display records.我设置了一些不允许显示记录的权限代码。 It makes sense as the datatable seemed to show up so I was thinking that it was some Entity Framework issue.这是有道理的,因为数据表似乎出现了,所以我认为这是一些实体框架问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM