How to dynamically display the attribute settings of jqGrid and jqGrid in jquery

Source: Internet
Author: User
Tags jqgrid

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.