Dynamically modify parameters submitted by jqgrid
Specific instructions can refer to the http://www.trirand.com/jqgridwiki/doku.php? Id = wiki: post_data_module
Here is an example: When you need to filter the display data of jqgrid based on user input, you can achieve this,
JS Code
- Username = $ ('# username'). Val (); // input value
- Usercode = $ ('# usercode'). Val (); // input value
- Jquery ('# grid_user'). appendpostdata ({Username: username, usercode: usercode}
- In this case, when the grid data is refreshed, the data submitted to the server contains the username and usercode.
Username = $ ('# username '). val (); // input value usercode = $ ('# usercode '). val (); // The input value jquery ('# grid_user '). appendpostdata ({Username: username, usercode: usercode}). When the grid data is refreshed, the data submitted to the server contains the username and usercode.
Add data items dynamically when submitting the editing form
How can I dynamically add or modify some projects when submitting a form editing request?
A typical example is to add the current time project to the submitted data when adding an article record.
Reference http://www.trirand.com/jqgridwiki/doku.php? Id = wiki: form_editing:
Before submitting a form, the event beforesubmit is triggered, so we can do something in this event.
JS Code
- // Before submission
- Fn_beforesubmit = function (postdata, formid ){
- // Add or modify the postdata project value
- Postdata ['uploaddate'] = new date (). Format ("yyyy/mm/DD ");
- Postdata ['uploadtime'] = new date (). Format ("HH: mm: SS ");
- Return [true, '']; // submit
- };
- // Add record options
- Options_add = {
- Width: 500,
- Height: 290,
- Reloadaftersubmit: True,
- Jqmodal: True,
- Beforesubmit: fn_beforesubmit,
- ......
- }
- // Configure jqgrid nav
- Jquery (pgridid ). jqgrid ('navgrid', ppageid, {EDIT: True, add: True, del: True, search: false, refresh: True, view: True, addtext: 'add ', edittext: 'modify', deltext: 'delete'}, // options
- {Height: 290, reloadaftersubmit: false, jqmodal: True, closeonescape: True, bottominfo: "Fields marked with * cannot be blank"}, // edit options
- Options_add, // Add options
- {Reloadaftersubmit: false, jqmodal: True, closeonescape: true}, // del options
- {Closeonescape: true}, // search options
- {Height: 250, jqmodal: false, closeonescape: true} // view options
- );
// Before submission, fn_beforesubmit = function (postdata, formid) {// Add or modify the postdata project value postdata ['uploaddate'] = new date (). format ("yyyy/mm/DD"); postdata ['uploadtime'] = new date (). format ("HH: mm: SS"); return [true, '']; // submit}; // Add record options options_add = {width: 500, height: 290, reloadaftersubmit: True, jqmodal: True, beforesubmit: fn_beforesubmit ,......} // configure jqgrid nav jquery (pgridid ). jqgrid ('navgrid', ppageid, {EDIT: True, add: True, del: True, search: false, refresh: True, view: True, addtext: 'add ', edittext: 'modify', deltext: 'delete'}, // options {Height: 290, reloadaftersubmit: false, jqmodal: True, closeonescape: True, bottominfo: "Fields marked with * cannot be blank"}, // edit options options_add, // Add options {reloadaftersubmit: false, jqmodal: True, closeonescape: true }, // del options {closeonescape: true}, // search options {Height: 250, jqmodal: false, closeonescape: true} // view options );