Jqgrid dynamically add data items

Source: Internet
Author: User
Tags jqgrid

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
  1. Username = $ ('# username'). Val (); // input value
  2. Usercode = $ ('# usercode'). Val (); // input value
  3. Jquery ('# grid_user'). appendpostdata ({Username: username, usercode: usercode}
  4. 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
  1. // Before submission
  2. Fn_beforesubmit = function (postdata, formid ){
  3. // Add or modify the postdata project value
  4. Postdata ['uploaddate'] = new date (). Format ("yyyy/mm/DD ");
  5. Postdata ['uploadtime'] = new date (). Format ("HH: mm: SS ");
  6. Return [true, '']; // submit
  7. };
  8. // Add record options
  9. Options_add = {
  10. Width: 500,
  11. Height: 290,
  12. Reloadaftersubmit: True,
  13. Jqmodal: True,
  14. Beforesubmit: fn_beforesubmit,
  15. ......
  16. }
  17. // Configure jqgrid nav
  18. Jquery (pgridid ). jqgrid ('navgrid', ppageid, {EDIT: True, add: True, del: True, search: false, refresh: True, view: True, addtext: 'add ', edittext: 'modify', deltext: 'delete'}, // options
  19. {Height: 290, reloadaftersubmit: false, jqmodal: True, closeonescape: True, bottominfo: "Fields marked with * cannot be blank"}, // edit options
  20. Options_add, // Add options
  21. {Reloadaftersubmit: false, jqmodal: True, closeonescape: true}, // del options
  22. {Closeonescape: true}, // search options
  23. {Height: 250, jqmodal: false, closeonescape: true} // view options
  24. );
// 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 );

 

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.