Tha*_*kur -1
我建议使用jqGrid(或者可能是其他一些java脚本网格)。从 MVC 控制器返回 ActionResult 作为 JSON 对象
public ActionResult UserList()
{
object userListData = null;
try
{
List<UserListViewModel> users = 'your code to get the user list'
userListData = new
{
page = 1,
records = users.Count,
rows = users
};
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength = int.MaxValue;
return new ContentResult()
{
Content = serializer.Serialize(userListData),
ContentType = "application/json",
};
}
Run Code Online (Sandbox Code Playgroud)
并在页面加载/jQuery 文档上调用此方法准备一些类似的东西。
$("#userTable").jqGrid({
url: '../User/UserList,
mtype: 'GET',
datatype: "json",
autowidth: true,
colNames: ['Id', 'First Name', 'Last Name'],
colModel: [
{ name: 'Id', key: true, hidden: true, fixed: false, shrinkToFit: false, align: 'left' },
{ name: 'FirstName', fixed: false, shrinkToFit: false, align: 'left' },
{ name: 'LastName', fixed: false, shrinkToFit: false, align: 'left' }
],
Run Code Online (Sandbox Code Playgroud)
有关 jqGrid 的更多信息,请参阅http://jqgrid.com/上的演示
| 归档时间: |
|
| 查看次数: |
6039 次 |
| 最近记录: |