我的视图中有一个DataTable,如下所示:
<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>
以及数据的赋值:
$("#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']]);
我知道我用下面的代码获得了正确的JSON数据:
[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);
}
但是,这些行都没有出现。我在这里做错了什么?实际上,如果我在加载表时通过将调试点放在删除点来进行调试,我可以看到数据,但它永远不会显示。
发布于 2016-05-10 09:50:53
不幸的是,这个问题是由使用我加载到主视图中的字母搜索引起的。开始筛选并显示局部视图后,筛选将继续在该局部视图中进行,实际上不显示任何结果。我有另一个关于这个问题的问题,目前还没有答案。
https://stackoverflow.com/questions/37113701
复制相似问题