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. CopyCode The 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.