MVC and Easyui DataGrid
No source of students jump to the sixth talk download source again.
We need a nice UI and do not automatically generate a spam UI for the system. We are in front of large data, we want to reduce the pressure on the page, do not traverse the list in the page
We chose Easyui's DataGrid, the most systematic form to display the results
This section knowledge points:
Make a JSON format in controller based on the DataGrid JSON format to the DataGrid
Our system seems to be getting more and more interesting,
First, start with the front end. The following shared creates a view template
<! DOCTYPE html>
The index view used by our system will basically reference this template
@using app.admin;
@using App.common;
@{viewbag.title = "Index";
Layout = "~/views/shared/_index_layout.cshtml"; } <table id= "List" ></table> <script type= "Text/javascript" > $ (Function () {$ (' #List ').
DataGrid ({url: '/syssample/getlist ', Width: $ (window). Width ()-Ten, Methord: ' Post ', Height: $ (window). Height () -35, Fitcolumns:true, sortname: ' Id ', Sortorde
R: ' Desc ', IDfield: ' Id ', striped:true,//odd-even line distinguish singleselect:true,//Radio mode
rownumbers:true,//line number columns: [[[{field: ' id ', title: ' Id ', width:80},
{field: ' Name ', title: ' Names ', width:120}, {field: ' Age ', Title: ' Ages ', width:80, align: ' right '}, {field: ' Bir ', title: ' Birthdays ', width:80, align: ' right '}, {field: ' Photo ', title: ' Photos ', width : 250},
{field: ' Note ', Title: ' Description ', width:60, align: ' center '}, {field: ' Createtime ', title:
' Creation time ', width:60, align: ' center '}]};
}); </script> index.cshtml
Add the GetLists method to the Ajax use of the view in Syssamplecontroller
[HttpPost]
Public Jsonresult getlist ()
{
list<syssamplemodel> List = m_bll. GetList ("");
var json = new
{Total
= list. Count,
rows = (from R in list
select New Syssamplemodel ()
{
Id = r.id,
Name = r.name, age
= R.A GE,
Bir = R.bir,
Photo = R.photo, note
= r.note,
createtime = R.createtime,
}). ToArray ()
};
Return JSON (JSON, jsonrequestbehavior.allowget);
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/aspx/