Generally, the basic attributes of a jqGrid are commonly used.
Copy codeThe Code is as follows:
$ ("# Id"). jqGrid ({
Url :"",
Datatype: "local ",
PostData: {strJson: Data },
Mtype: "post ",
Height: 45,
Width: 450,
RowNum: rum, // number of records per page
Pgtext: "{0} page {1 ",
Pgbuttons: true,
Autoheight: true,
Rownumbers: false, // whether to display the number of rows
Pgbuttons: true, // whether the pagination button is displayed
Pginput: true, // whether the number of pages allowed to be input
Scrollrows: false, // whether the row scroll bar is displayed
Viewrecords: true, // whether to display the total number of records
Multiselect: true, // whether to display the check box
Recordpos: "left", // location where the number of records is displayed
Sortorder: "asc", // sorting method
Pager: "# Pager"
)}
If you do not want to execute the table initialization method during initialization, you must set the url to null and the ype to "local". Otherwise, a js error occurs, the button on the page does not work.
If you need to initialize the table at the beginning, you need to set the url value. net mvc Architecture, that is, the format "/controller/action/", the first "/" is required, otherwise it cannot enter the background action, the last "/" does not seem to be necessary. It is generally added. After setting the url, you must also note that datatype must match the data type of postData. Otherwise, an error may occur. For example, if datatype: "json", postData must be a json object.
If you want to perform table initialization dynamically, you do not need to set the url value at the beginning. datatype is set to "local" (otherwise, an error is reported ). Then, the jqGrid initialization action is triggered dynamically.
For example, the Code is as follows:
Copy codeThe Code is as follows:
// Double-click a row event
OndblClickRow: function (){
CourseData = JSON. stringify ({
StuNum: studentNum,
RowNum: rum,
Page: 1
});
JQuery ("# courseInfoGrid"). jqGrid ("setGridParam ",{
Url: "/PersonalArrearsSettlement/GetStudentCourseInfo", // set the url of the table
Datatype: "json", // sets the Data Type
PostData: {strJson: courseData}
});
In this way, you can dynamically display table data.