Jqgrid POST request, re-fetch parameter load data

Source: Internet
Author: User
Tags json jqgrid

Recently using Jqgrid to develop an interface, very easy to use a framework, directly re-use the existing code, using GET request parameters, stitching behind the URL, encountered in the input box modified parameters after the background data is not acquired problems.

This problem has been tangled for a long while, by searching the Web page to understand that Jqgrid has triggers to reload data.

          $ (' #Buttonid '). On (' click ', Function () {     ///Page ' button ' click ' event, retrieve parameter after parameters are sent, and reload data.
              keyword = $ ("#jjinputid"). Val ();       Get the input box content
               cchl= "Jijin";
                $ ("#dataTable"). Jqgrid (' Setgridparam ', {
                    datatype: ' JSON ',
                    postdata:{' keyword ': encodeURI (encodeURI ( Keyword)},//Send data
                    page:1
                }). Trigger ("Reloadgrid"); Reload
        });


Here is the code to load the data, there are two important parameters, Mtype: ' POST ', define the request type, PostData define the parameter type

            JQuery ("#dataTable"). Jqgrid ({
            URL: ' rest/jjyqgk/getdata ',
             editurl: ' Rest/tabconfig/edittab ',
            DataType: "JSON",
            mtype: ' POST ',
            hidegrid:false,
            colnames:
            postdata: {  
                cchl:cchl,  
                keyword : Keyword  
              },  
               rownum:10,
               rowlist:[10,20,30,40,50],
               pager:jquery (' #pager '),
               sortname: ' Id ',
            viewrecords:true,
            sortorder: "desc",
            jsonreader: {
                repeatitems:false,
                ID: "0"
            },
            altrows:true,
           ///Altclass: ' SomeClass ',
            rownumbers:true,
            //caption: ' column list ',
            width: Pagedoc.getwidth (),
            height:pagedoc.getHeight ()
        });


Reference pages: http://blog.csdn.net/enter89/article/details/8363189                     http://www.huosen.net/archives/147.html

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.