jqGrid post請求,重新擷取參數載入資料

來源:互聯網
上載者:User

  最近使用jqgrid開發一個介面,挺易用的一個架構,直接複用現有的代碼,使用get請求傳參,拼接在url後面,遇到了輸入框修改參數後後台資料擷取不到的問題。

這個問題糾結了半天,通過搜尋網頁,瞭解jqGrid有觸發器可以重新載入資料。

          $('#Buttonid').on('click', function() {     //頁面上的button按鈕的click事件,重新擷取參數後發送參數,然後重新載入資料。              keyword = $("#jjinputid").val();       //擷取輸入框內容               cchl="jijin";                $("#dataTable").jqGrid('setGridParam',{                    datatype:'json',                    postData:{'keyword':encodeURI(encodeURI(keyword))}, //發送資料                    page:1                }).trigger("reloadGrid"); //重新載入        });

    

下面是載入資料的代碼,有兩個重要參數, mtype: 'POST',定義請求類型,postData定義參數種類

 

            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: "欄目列表",            width: pagedoc.getWidth(),            height: pagedoc.getHeight()        });

參考網頁:http://blog.csdn.net/enter89/article/details/8363189                    http://www.huosen.net/archives/147.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.