grid.postext.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. ;(function($){
  2. /**
  3. * jqGrid extension
  4. * Paul Tiseo ptiseo@wasteconsultants.com
  5. *
  6. * Dual licensed under the MIT and GPL licenses:
  7. * http://www.opensource.org/licenses/mit-license.php
  8. * http://www.gnu.org/licenses/gpl-2.0.html
  9. **/
  10. $.jgrid.extend({
  11. getPostData : function(){
  12. var $t = this[0];
  13. if(!$t.grid) { return; }
  14. return $t.p.postData;
  15. },
  16. setPostData : function( newdata ) {
  17. var $t = this[0];
  18. if(!$t.grid) { return; }
  19. // check if newdata is correct type
  20. if ( typeof(newdata) === 'object' ) {
  21. $t.p.postData = newdata;
  22. }
  23. else {
  24. alert("Error: cannot add a non-object postData value. postData unchanged.");
  25. }
  26. },
  27. appendPostData : function( newdata ) {
  28. var $t = this[0];
  29. if(!$t.grid) { return; }
  30. // check if newdata is correct type
  31. if ( typeof(newdata) === 'object' ) {
  32. $.extend($t.p.postData, newdata);
  33. }
  34. else {
  35. alert("Error: cannot append a non-object postData value. postData unchanged.");
  36. }
  37. },
  38. setPostDataItem : function( key, val ) {
  39. var $t = this[0];
  40. if(!$t.grid) { return; }
  41. $t.p.postData[key] = val;
  42. },
  43. getPostDataItem : function( key ) {
  44. var $t = this[0];
  45. if(!$t.grid) { return; }
  46. return $t.p.postData[key];
  47. },
  48. removePostDataItem : function( key ) {
  49. var $t = this[0];
  50. if(!$t.grid) { return; }
  51. delete $t.p.postData[key];
  52. },
  53. getUserData : function(){
  54. var $t = this[0];
  55. if(!$t.grid) { return; }
  56. return $t.p.userData;
  57. },
  58. getUserDataItem : function( key ) {
  59. var $t = this[0];
  60. if(!$t.grid) { return; }
  61. return $t.p.userData[key];
  62. }
  63. });
  64. })(jQuery);