我目前正在使用asp.net mvc3和bootstrap自行完成一个简单的项目。
我在下面的代码工作完美。但我的问题是在COMMIT
显示时。正如您在代码I Data Table
中看到的那样order
和控制器中的结果很好,但问题出在数据表中。
ID的
Pres - 1
诉P - 2
Sec - 3
代码
PositionId
JS
public JsonResult LoadTableTest()
{
var Data = new List<object>();
Data = (from a in db.testVotings
orderby a.PositionID
select new
{
PosId = a.PositionID,
testID = a.testID,
Fullname = a.Fullname,
Position = a.Position,
party = a.party
}).ToList<object>();
return Json(new
{
data = Data
}, JsonRequestBehavior.AllowGet);
}
HTML
var dataTablestest = $("#tbltest").DataTable({
responsive: true,
processing: true,
info: true,
search: true,
stateSave: true,
order: [[1, "asc"]],// [2, "asc"]],
lengthMenu: [[50, 100, 200, -1], [50, 100, 200, "All"]],
ajax: { "url": "/Voting/LoadTableTest" },
columns:
[
{ data: "PosId", title: "", orderable: true ,visible: false, searchable: false },
{ data: "testID", title: "",orderable: false, visible: false, searchable: false },
{ data: "Fullname", title: "FullName",orderable: false, sClass: "alignRight" },
{ data: "Position", title: "Position",orderable: false, sClass: "alignRight" },
{ data: "party", title: "Party",orderable: false, sClass: "alignRight" },
{ data: "ActionMenu", title: "Click to vote", searchable: false, orderable: false, sClass: "alignCenter",
"mRender": function (data) {
return '<center><label><input class="checkId" type="checkbox" /></label></center>';
}
}
]
});