Datatables 数据表中未显示行

Datatables 数据表中未显示行,datatables,Datatables,我的视图中有一个数据表,如下所示: <table id="tblProviders" style="font-size:x-small;width:100%; border: 1px solid black;"> <caption>Assigned Providers</caption> <thead> <tr>

我的视图中有一个数据表,如下所示:

 <table id="tblProviders" style="font-size:x-small;width:100%; border: 1px solid black;">
                <caption>Assigned Providers</caption>
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>Name</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Role</th>
                        <th>Remove</th>
                    </tr>
                </thead>
            </table>

但没有一行出现。我做错了什么?事实上,如果我通过在删除点放置调试点来调试表的加载,我会看到数据,但它从不显示。

不幸的是,问题是由于使用我加载到主视图中的字母搜索造成的。一旦过滤开始并显示部分视图,过滤将在该部分视图中继续,实际上不会显示任何结果。关于这个问题,我还有一个问题还没有答案。

您使用的是什么版本的DataTables?@thirtydot我使用的是1.10.10这里有一个JSFIDLE应该会有所帮助:(我使用JSFIDLE的特殊策略来模拟JSON响应)
mData
很重要,至少对于我选择的数据格式是如此。另外,您应该切换到新的API,这样就不那么容易混淆了。我将在可能的时候更新我的答案,使其有意义。下面是一个不使用
mData
的示例,使用我认为您正在使用的相同数据格式:。我认为你的问题在于你没有像这样包装你的数据:
{“数据”:[[“id 1”、“姓名1”、“电子邮件1”、“电话1”、“角色1”]、[“id 2”、“姓名2”、“电子邮件2”、“电话2”、“角色2”]}
。如果不是这样的话,我想这是我从你问题的代码中看不到的。
 $("#tblProviders").dataTable({
        bProcessing: true,
        sAjaxSource: '@Url.Action("GetProvidersById")?id=' + $("#txtid").val(),
        bJQueryUI: true,
        sProcessing: "<img src='~/Images/spinner.gif' />",
        dom: 'T<"clear">rtip',
        "pageLength": 5,
        bAutoWidth: false,
        "oLanguage": {
            sEmptyTable: "There are no Providers at this time",
            sZeroRecords: "There are no Providers at this time"
        },
        "aoColumns": [
            { "sWidth": "1%", sClass: "smallFonts" },
            { "sWidth": "15%", sClass: "smallFonts" },
            { "sWidth": "15%", sClass: "smallFonts" },
            { "sWidth": "15%", sClass: "smallFonts" },
            { "sWidth": "15%", sClass: "smallfonts" },
            {
                "sWidth": "15%", sClass: "centerbutton", "sName": "UserId", "mRender": function (data, type, row) {

                    return "<button type='button' class='displaybutton' id='" + row[0] + "' onclick=RemoveProvider(this);return false; >Remove</button>";
                }
            }
        ],
        tableTools: {
            "sSwfPath": "../../Scripts/swf/copy_csv_xls_pdf.swf",
            "aButtons": [

            ]

        }
    });
    $("#tblProviders").dataTable().fnSetColumnVis(0, false);
    otab = $("#tblProviders").dataTable();
    otab.fnSort([[1, 'asc']]);
 [HttpGet]
    public ActionResult GetProvidersId(string id)
    {
        return Json(new
        {
            aaData = Repository.GetProvidersById(id).Select(x => new String[] {
                x.ID.ToString(),
                x.FirstName + " " + x.LastName,
                x.Email,
                x.Phone,
                x.Role,
            })
        }, JsonRequestBehavior.AllowGet);
    }