jqgrid-jquery-rails 4.5.400 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1 -1
  4. data/lib/jqgrid-jquery-rails/version.rb +2 -2
  5. data/spec/features/asset_pipeline_spec.rb +1 -1
  6. data/vendor/assets/javascripts/i18n/grid.locale-ar.js +128 -126
  7. data/vendor/assets/javascripts/i18n/grid.locale-bg.js +5 -3
  8. data/vendor/assets/javascripts/i18n/grid.locale-bg1251.js +1 -1
  9. data/vendor/assets/javascripts/i18n/grid.locale-cat.js +5 -3
  10. data/vendor/assets/javascripts/i18n/grid.locale-cn.js +5 -3
  11. data/vendor/assets/javascripts/i18n/grid.locale-cs.js +5 -3
  12. data/vendor/assets/javascripts/i18n/grid.locale-da.js +5 -3
  13. data/vendor/assets/javascripts/i18n/grid.locale-de.js +41 -39
  14. data/vendor/assets/javascripts/i18n/grid.locale-dk.js +5 -3
  15. data/vendor/assets/javascripts/i18n/grid.locale-el.js +5 -3
  16. data/vendor/assets/javascripts/i18n/grid.locale-en.js +5 -3
  17. data/vendor/assets/javascripts/i18n/grid.locale-es.js +5 -3
  18. data/vendor/assets/javascripts/i18n/grid.locale-fa.js +146 -144
  19. data/vendor/assets/javascripts/i18n/grid.locale-fi.js +131 -129
  20. data/vendor/assets/javascripts/i18n/grid.locale-fr.js +128 -126
  21. data/vendor/assets/javascripts/i18n/grid.locale-gl.js +5 -3
  22. data/vendor/assets/javascripts/i18n/grid.locale-he.js +5 -3
  23. data/vendor/assets/javascripts/i18n/grid.locale-hr.js +164 -162
  24. data/vendor/assets/javascripts/i18n/grid.locale-hr1250.js +164 -162
  25. data/vendor/assets/javascripts/i18n/grid.locale-hu.js +5 -3
  26. data/vendor/assets/javascripts/i18n/grid.locale-id.js +170 -168
  27. data/vendor/assets/javascripts/i18n/grid.locale-is.js +128 -126
  28. data/vendor/assets/javascripts/i18n/grid.locale-it.js +1 -1
  29. data/vendor/assets/javascripts/i18n/grid.locale-ja.js +6 -3
  30. data/vendor/assets/javascripts/i18n/grid.locale-kr.js +5 -3
  31. data/vendor/assets/javascripts/i18n/grid.locale-lt.js +5 -3
  32. data/vendor/assets/javascripts/i18n/grid.locale-mne.js +130 -128
  33. data/vendor/assets/javascripts/i18n/grid.locale-nl.js +5 -3
  34. data/vendor/assets/javascripts/i18n/grid.locale-no.js +1 -1
  35. data/vendor/assets/javascripts/i18n/grid.locale-pl.js +5 -3
  36. data/vendor/assets/javascripts/i18n/grid.locale-pt-br.js +4 -2
  37. data/vendor/assets/javascripts/i18n/grid.locale-pt.js +6 -4
  38. data/vendor/assets/javascripts/i18n/grid.locale-ro.js +5 -3
  39. data/vendor/assets/javascripts/i18n/grid.locale-ru.js +66 -64
  40. data/vendor/assets/javascripts/i18n/grid.locale-sk.js +5 -3
  41. data/vendor/assets/javascripts/i18n/grid.locale-sr-latin.js +130 -128
  42. data/vendor/assets/javascripts/i18n/grid.locale-sr.js +130 -128
  43. data/vendor/assets/javascripts/i18n/grid.locale-sv.js +5 -3
  44. data/vendor/assets/javascripts/i18n/grid.locale-th.js +130 -128
  45. data/vendor/assets/javascripts/i18n/grid.locale-tr.js +5 -3
  46. data/vendor/assets/javascripts/i18n/grid.locale-tw.js +6 -4
  47. data/vendor/assets/javascripts/i18n/grid.locale-ua.js +5 -3
  48. data/vendor/assets/javascripts/i18n/grid.locale-vi.js +5 -3
  49. data/vendor/assets/javascripts/jquery.jqGrid.js +1109 -536
  50. data/vendor/assets/stylesheets/ui.jqgrid.css +17 -8
  51. metadata +2 -2
@@ -19,8 +19,10 @@ $.extend($.jgrid,{
19
19
  caption: "Arama...",
20
20
  Find: "Bul",
21
21
  Reset: "Temizle",
22
- odata: [{ oper:'eq', text:"eşit"},{ oper:'ne', text:"eşit değil"},{ oper:'lt', text:"daha az"},{ oper:'le', text:"daha az veya eşit"},{ oper:'gt', text:"daha fazla"},{ oper:'ge', text:"daha fazla veya eşit"},{ oper:'bw', text:"ile başlayan"},{ oper:'bn', text:"ile başlamayan"},{ oper:'in', text:"içinde"},{ oper:'ni', text:"içinde değil"},{ oper:'ew', text:"ile biten"},{ oper:'en', text:"ile bitmeyen"},{ oper:'cn', text:"içeren"},{ oper:'nc', text:"içermeyen"}],
23
- groupOps: [ { op: "VE", text: "tüm" }, { op: "VEYA", text: "herhangi" } ]
22
+ odata: [{ oper:'eq', text:"eşit"},{ oper:'ne', text:"eşit değil"},{ oper:'lt', text:"daha az"},{ oper:'le', text:"daha az veya eşit"},{ oper:'gt', text:"daha fazla"},{ oper:'ge', text:"daha fazla veya eşit"},{ oper:'bw', text:"ile başlayan"},{ oper:'bn', text:"ile başlamayan"},{ oper:'in', text:"içinde"},{ oper:'ni', text:"içinde değil"},{ oper:'ew', text:"ile biten"},{ oper:'en', text:"ile bitmeyen"},{ oper:'cn', text:"içeren"},{ oper:'nc', text:"içermeyen"},{ oper:'nu', text:'is null'},{ oper:'nn', text:'is not null'}],
23
+ groupOps: [ { op: "VE", text: "tüm" }, { op: "VEYA", text: "herhangi" }],
24
+ operandTitle : "Click to select search operation.",
25
+ resetTitle : "Reset Search Value"
24
26
  },
25
27
  edit : {
26
28
  addCaption: "Kayıt Ekle",
@@ -100,7 +102,7 @@ $.extend($.jgrid,{
100
102
  S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
101
103
  srcformat: 'Y-m-d',
102
104
  newformat: 'd/m/Y',
103
- parseRe : /[Tt\\\/:_;.,\t\s-]/,
105
+ parseRe : /[#%\\\/:_;.,\t\s-]/,
104
106
  masks : {
105
107
  ISO8601Long:"Y-m-d H:i:s",
106
108
  ISO8601Short:"Y-m-d",
@@ -20,8 +20,10 @@ $.extend($.jgrid,{
20
20
  caption: "搜尋...",
21
21
  Find: "搜尋",
22
22
  Reset: "重設",
23
- odata: [{ oper:'eq', text:"等於 "},{ oper:'ne', text:"不等於 "},{ oper:'lt', text:"小於 "},{ oper:'le', text:"小於等於 "},{ oper:'gt', text:"大於 "},{ oper:'ge', text:"大於等於 "},{ oper:'bw', text:"開始於 "},{ oper:'bn', text:"不開始於 "},{ oper:'in', text:"在其中 "},{ oper:'ni', text:"不在其中 "},{ oper:'ew', text:"結束於 "},{ oper:'en', text:"不結束於 "},{ oper:'cn', text:"包含 "},{ oper:'nc', text:"不包含 "}],
24
- groupOps: [ { op: "AND", text: "所有" }, { op: "OR", text: "任一" } ]
23
+ odata: [{ oper:'eq', text:"等於 "},{ oper:'ne', text:"不等於 "},{ oper:'lt', text:"小於 "},{ oper:'le', text:"小於等於 "},{ oper:'gt', text:"大於 "},{ oper:'ge', text:"大於等於 "},{ oper:'bw', text:"開始於 "},{ oper:'bn', text:"不開始於 "},{ oper:'in', text:"在其中 "},{ oper:'ni', text:"不在其中 "},{ oper:'ew', text:"結束於 "},{ oper:'en', text:"不結束於 "},{ oper:'cn', text:"包含 "},{ oper:'nc', text:"不包含 "},{ oper:'nu', text:'is null'},{ oper:'nn', text:'is not null'}],
24
+ groupOps: [ { op: "AND", text: "所有" }, { op: "OR", text: "任一" } ],
25
+ operandTitle : "Click to select search operation.",
26
+ resetTitle : "Reset Search Value"
25
27
  },
26
28
  edit : {
27
29
  addCaption: "新增記錄",
@@ -100,10 +102,10 @@ $.extend($.jgrid,{
100
102
  "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
101
103
  ],
102
104
  AmPm : ["上午","下午","上午","下午"],
103
- S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
105
+ S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
104
106
  srcformat: 'Y-m-d',
105
107
  newformat: 'm-d-Y',
106
- parseRe : /[Tt\\\/:_;.,\t\s-]/,
108
+ parseRe : /[#%\\\/:_;.,\t\s-]/,
107
109
  masks : {
108
110
  ISO8601Long:"Y-m-d H:i:s",
109
111
  ISO8601Short:"Y-m-d",
@@ -19,8 +19,10 @@ $.extend($.jgrid,{
19
19
  caption: "Пошук...",
20
20
  Find: "Знайти",
21
21
  Reset: "Скидання",
22
- odata: [{ oper:'eq', text:"рівно"},{ oper:'ne', text:"не рівно"},{ oper:'lt', text:"менше"},{ oper:'le', text:"менше або рівне"},{ oper:'gt', text:"більше"},{ oper:'ge', text:"більше або рівне"},{ oper:'bw', text:"починається з"},{ oper:'bn', text:"не починається з"},{ oper:'in', text:"знаходиться в"},{ oper:'ni', text:"не знаходиться в"},{ oper:'ew', text:"закінчується на"},{ oper:'en', text:"не закінчується на"},{ oper:'cn', text:"містить"},{ oper:'nc', text:"не містить"}],
23
- groupOps: [ { op: "AND", text: "все" }, { op: "OR", text: "будь-який" } ]
22
+ odata: [{ oper:'eq', text:"рівно"},{ oper:'ne', text:"не рівно"},{ oper:'lt', text:"менше"},{ oper:'le', text:"менше або рівне"},{ oper:'gt', text:"більше"},{ oper:'ge', text:"більше або рівне"},{ oper:'bw', text:"починається з"},{ oper:'bn', text:"не починається з"},{ oper:'in', text:"знаходиться в"},{ oper:'ni', text:"не знаходиться в"},{ oper:'ew', text:"закінчується на"},{ oper:'en', text:"не закінчується на"},{ oper:'cn', text:"містить"},{ oper:'nc', text:"не містить"},{ oper:'nu', text:'is null'},{ oper:'nn', text:'is not null'}],
23
+ groupOps: [ { op: "AND", text: "все" }, { op: "OR", text: "будь-який" }],
24
+ operandTitle : "Click to select search operation.",
25
+ resetTitle : "Reset Search Value"
24
26
  },
25
27
  edit : {
26
28
  addCaption: "Додати запис",
@@ -101,7 +103,7 @@ $.extend($.jgrid,{
101
103
  S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
102
104
  srcformat: 'Y-m-d',
103
105
  newformat: 'd.m.Y',
104
- parseRe : /[Tt\\\/:_;.,\t\s-]/,
106
+ parseRe : /[#%\\\/:_;.,\t\s-]/,
105
107
  masks : {
106
108
  ISO8601Long:"Y-m-d H:i:s",
107
109
  ISO8601Short:"Y-m-d",
@@ -19,8 +19,10 @@ $.extend($.jgrid,{
19
19
  caption: "Tìm kiếm...",
20
20
  Find: "Tìm",
21
21
  Reset: "Khởi tạo lại",
22
- odata: [{ oper:'eq', text:"bằng"},{ oper:'ne', text:"không bằng"},{ oper:'lt', text:"bé hơn"},{ oper:'le', text:"bé hơn hoặc bằng"},{ oper:'gt', text:"lớn hơn"},{ oper:'ge', text:"lớn hơn hoặc bằng"},{ oper:'bw', text:"bắt đầu với"},{ oper:'bn', text:"không bắt đầu với"},{ oper:'in', text:"trong"},{ oper:'ni', text:"không nằm trong"},{ oper:'ew', text:"kết thúc với"},{ oper:'en', text:"không kết thúc với"},{ oper:'cn', text:"chứa"},{ oper:'nc', text:"không chứa"}],
23
- groupOps: [ { op: "VÀ", text: "tất cả" }, { op: "HOẶC", text: "bất kỳ" } ]
22
+ odata: [{ oper:'eq', text:"bằng"},{ oper:'ne', text:"không bằng"},{ oper:'lt', text:"bé hơn"},{ oper:'le', text:"bé hơn hoặc bằng"},{ oper:'gt', text:"lớn hơn"},{ oper:'ge', text:"lớn hơn hoặc bằng"},{ oper:'bw', text:"bắt đầu với"},{ oper:'bn', text:"không bắt đầu với"},{ oper:'in', text:"trong"},{ oper:'ni', text:"không nằm trong"},{ oper:'ew', text:"kết thúc với"},{ oper:'en', text:"không kết thúc với"},{ oper:'cn', text:"chứa"},{ oper:'nc', text:"không chứa"},{ oper:'nu', text:'is null'},{ oper:'nn', text:'is not null'}],
23
+ groupOps: [ { op: "VÀ", text: "tất cả" }, { op: "HOẶC", text: "bất kỳ" } ],
24
+ operandTitle : "Click to select search operation.",
25
+ resetTitle : "Reset Search Value"
24
26
  },
25
27
  edit : {
26
28
  addCaption: "Thêm bản ghi",
@@ -102,7 +104,7 @@ $.extend($.jgrid,{
102
104
  S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
103
105
  srcformat: 'Y-m-d',
104
106
  newformat: 'n/j/Y',
105
- parseRe : /[Tt\\\/:_;.,\t\s-]/,
107
+ parseRe : /[#%\\\/:_;.,\t\s-]/,
106
108
  masks : {
107
109
  // see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
108
110
  // and see http://docs.jquery.com/UI/Datepicker/formatDate
@@ -2,12 +2,12 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license jqGrid 4.5.4 - jQuery Grid
5
+ * @license jqGrid 4.6.0 - jQuery Grid
6
6
  * Copyright (c) 2008, Tony Tomov, tony@trirand.com
7
7
  * Dual licensed under the MIT and GPL licenses
8
8
  * http://www.opensource.org/licenses/mit-license.php
9
9
  * http://www.gnu.org/licenses/gpl-2.0.html
10
- * Date: 2013-10-06
10
+ * Date: 2014-02-20
11
11
  */
12
12
  //jsHint options
13
13
  /*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */
@@ -17,7 +17,7 @@
17
17
  "use strict";
18
18
  $.jgrid = $.jgrid || {};
19
19
  $.extend($.jgrid,{
20
- version : "4.5.4",
20
+ version : "4.6.0",
21
21
  htmlDecode : function(value){
22
22
  if(value && (value==='&nbsp;' || value==='&#160;' || (value.length===1 && value.charCodeAt(0)===160))) { return "";}
23
23
  return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
@@ -99,7 +99,7 @@ $.extend($.jgrid,{
99
99
  }
100
100
  // old lang files
101
101
  if(opts.parseRe === undefined ) {
102
- opts.parseRe = /[Tt\\\/:_;.,\t\s-]/;
102
+ opts.parseRe = /[#%\\\/:_;.,\t\s-]/;
103
103
  }
104
104
  if( opts.masks.hasOwnProperty(format) ) { format = opts.masks[format]; }
105
105
  if(date && date != null) {
@@ -118,8 +118,13 @@ $.extend($.jgrid,{
118
118
  timestamp.setTime(Number(Number(timestamp) + (offset * 60 * 1000)));
119
119
  }
120
120
  } else {
121
- date = String(date).replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe);
122
- format = format.replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe);
121
+ var offset = 0;
122
+ //Support ISO8601Long that have Z at the end to indicate UTC timezone
123
+ if(opts.srcformat === 'ISO8601Long' && date.charAt(date.length - 1) === 'Z') {
124
+ offset -= (new Date()).getTimezoneOffset();
125
+ }
126
+ date = String(date).replace(/\T/g,"#").replace(/\t/,"%").split(opts.parseRe);
127
+ format = format.replace(/\T/g,"#").replace(/\t/,"%").split(opts.parseRe);
123
128
  // parsing for month names
124
129
  for(k=0,hl=format.length;k<hl;k++){
125
130
  if(format[k] === 'M') {
@@ -160,6 +165,10 @@ $.extend($.jgrid,{
160
165
  if (ty >= 70 && ty <= 99) {ts.y = 1900+ts.y;}
161
166
  else if (ty >=0 && ty <=69) {ts.y= 2000+ts.y;}
162
167
  timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
168
+ //Apply offset to show date as local time.
169
+ if(offset > 0) {
170
+ timestamp.setTime(Number(Number(timestamp) + (offset * 60 * 1000)));
171
+ }
163
172
  }
164
173
  } else {
165
174
  timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
@@ -437,9 +446,10 @@ $.extend($.jgrid,{
437
446
  var by=_sorting[q].by,
438
447
  dir=_sorting[q].dir,
439
448
  type = _sorting[q].type,
440
- dfmt = _sorting[q].datefmt;
449
+ dfmt = _sorting[q].datefmt,
450
+ sfunc = _sorting[q].sfunc;
441
451
  if(q===_sorting.length-1){
442
- return self._getOrder(d, by, dir, type, dfmt);
452
+ return self._getOrder(d, by, dir, type, dfmt, sfunc);
443
453
  }
444
454
  q++;
445
455
  var values=self._getGroup(d,by,dir,type,dfmt), results=[], i, j, sorted;
@@ -451,7 +461,7 @@ $.extend($.jgrid,{
451
461
  }
452
462
  return results;
453
463
  };
454
- this._getOrder=function(data,by,dir,type, dfmt){
464
+ this._getOrder=function(data,by,dir,type, dfmt, sfunc){
455
465
  var sortData=[],_sortData=[], newDir = dir==="a" ? 1 : -1, i,ab,j,
456
466
  findSortKey;
457
467
 
@@ -483,12 +493,19 @@ $.extend($.jgrid,{
483
493
  ab = findSortKey(ab, v);
484
494
  _sortData.push({ 'vSort': ab,'index':i});
485
495
  });
486
-
487
- _sortData.sort(function(a,b){
488
- a = a.vSort;
489
- b = b.vSort;
490
- return self._compare(a,b,newDir);
491
- });
496
+ if($.isFunction(sfunc)) {
497
+ _sortData.sort(function(a,b){
498
+ a = a.vSort;
499
+ b = b.vSort;
500
+ return sfunc.call(this,a,b,newDir);
501
+ });
502
+ } else {
503
+ _sortData.sort(function(a,b){
504
+ a = a.vSort;
505
+ b = b.vSort;
506
+ return self._compare(a,b,newDir);
507
+ });
508
+ }
492
509
  j=0;
493
510
  var nrec= data.length;
494
511
  // overhead, but we do not change the original data.
@@ -679,7 +696,7 @@ $.extend($.jgrid,{
679
696
  if(_useProperties){
680
697
  self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(v)+'"'));
681
698
  }else{
682
- length=_trim?$.trim(v.toString()).length:v.toString().length;
699
+ if (v!=null) { length=_trim?$.trim(v.toString()).length:v.toString().length; }
683
700
  self._append(self._getStr('this')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(f)+'"'));
684
701
  }
685
702
  self._setCommand(self.startsWith,f);
@@ -713,13 +730,14 @@ $.extend($.jgrid,{
713
730
  }
714
731
  return self._getGroup(_data,by,dir,type, datefmt);
715
732
  };
716
- this.orderBy=function(by,dir,stype, dfmt){
733
+ this.orderBy=function(by,dir,stype, dfmt, sfunc){
717
734
  dir = dir == null ? "a" :$.trim(dir.toString().toLowerCase());
718
735
  if(stype == null) { stype = "text"; }
719
736
  if(dfmt == null) { dfmt = "Y-m-d"; }
737
+ if(sfunc == null) { sfunc = false; }
720
738
  if(dir==="desc"||dir==="descending"){dir="d";}
721
739
  if(dir==="asc"||dir==="ascending"){dir="a";}
722
- _sorting.push({by:by,dir:dir,type:stype, datefmt: dfmt});
740
+ _sorting.push({by:by,dir:dir,type:stype, datefmt: dfmt, sfunc: sfunc});
723
741
  return self;
724
742
  };
725
743
  return self;
@@ -849,7 +867,7 @@ $.fn.jqGrid = function( pin ) {
849
867
  data : [],
850
868
  _index : {},
851
869
  grouping : false,
852
- groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus', displayField: []},
870
+ groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus', displayField: [], groupSummaryPos:[], formatDisplayField : [], _locgr : false},
853
871
  ignoreCase : false,
854
872
  cmTemplate : {},
855
873
  idPrefix : "",
@@ -860,10 +878,11 @@ $.fn.jqGrid = function( pin ) {
860
878
  cols:[],
861
879
  footers: [],
862
880
  dragStart: function(i,x,y) {
863
- this.resizing = { idx: i, startX: x.clientX, sOL : x.clientX-6};
881
+ var gridLeftPos = $(this.bDiv).offset().left;
882
+ this.resizing = { idx: i, startX: x.clientX, sOL : x.clientX - gridLeftPos };
864
883
  this.hDiv.style.cursor = "col-resize";
865
884
  this.curGbox = $("#rs_m"+$.jgrid.jqID(p.id),"#gbox_"+$.jgrid.jqID(p.id));
866
- this.curGbox.css({display:"block",left:x.clientX-6,top:y[1],height:y[2]});
885
+ this.curGbox.css({display:"block",left:x.clientX-gridLeftPos,top:y[1],height:y[2]});
867
886
  $(ts).triggerHandler("jqGridResizeStart", [x, i]);
868
887
  if($.isFunction(p.resizeStart)) { p.resizeStart.call(ts,x,i); }
869
888
  document.onselectstart=function(){return false;};
@@ -1326,7 +1345,10 @@ $.fn.jqGrid = function( pin ) {
1326
1345
  rowData[iStartTrTag] = constructTr(rid, hiderow, cn1, rd, xmlr, false);
1327
1346
  rowData.push("</tr>");
1328
1347
  if(ts.p.grouping) {
1329
- grpdata = groupingPrepare.call(self,rowData, grpdata, rd, j);
1348
+ grpdata.push( rowData );
1349
+ if(!ts.p.groupingView._locgr) {
1350
+ groupingPrepare.call(self, rd, j );
1351
+ }
1330
1352
  rowData = [];
1331
1353
  }
1332
1354
  if(locdata || ts.p.treeGrid === true) {
@@ -1349,7 +1371,9 @@ $.fn.jqGrid = function( pin ) {
1349
1371
  if(ts.p.gridview === true) {
1350
1372
  fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0;
1351
1373
  if(ts.p.grouping) {
1352
- self.jqGrid('groupingRender',grpdata,ts.p.colModel.length);
1374
+ if(!locdata) {
1375
+ self.jqGrid('groupingRender',grpdata,ts.p.colModel.length, ts.p.page, rn);
1376
+ }
1353
1377
  grpdata = null;
1354
1378
  } else if(ts.p.treeGrid === true && fpos > 0) {
1355
1379
  $(ts.rows[fpos]).after(rowData.join(''));
@@ -1396,11 +1420,19 @@ $.fn.jqGrid = function( pin ) {
1396
1420
  }
1397
1421
  }
1398
1422
  rd[xmlid] = $.jgrid.stripPref(ts.p.idPrefix, rid);
1423
+ if(ts.p.grouping) {
1424
+ groupingPrepare.call(self, rd, ir );
1425
+ }
1399
1426
  ts.p.data.push(rd);
1400
1427
  ts.p._index[rd[xmlid]] = ts.p.data.length-1;
1401
1428
  rd = {};
1402
1429
  ir++;
1403
1430
  }
1431
+ if(ts.p.grouping) {
1432
+ ts.p.groupingView._locgr = true;
1433
+ self.jqGrid('groupingRender', grpdata, ts.p.colModel.length, ts.p.page, rn);
1434
+ grpdata = null;
1435
+ }
1404
1436
  }
1405
1437
  },
1406
1438
  addJSONData = function(data,t, rcnt, more, adjust) {
@@ -1510,7 +1542,10 @@ $.fn.jqGrid = function( pin ) {
1510
1542
  rowData[iStartTrTag] = constructTr(idr, hiderow, cn1, rd, cur, selr);
1511
1543
  rowData.push( "</tr>" );
1512
1544
  if(ts.p.grouping) {
1513
- grpdata = groupingPrepare.call(self,rowData, grpdata, rd, i);
1545
+ grpdata.push( rowData );
1546
+ if(!ts.p.groupingView._locgr) {
1547
+ groupingPrepare.call(self, rd, i);
1548
+ }
1514
1549
  rowData = [];
1515
1550
  }
1516
1551
  if(locdata || ts.p.treeGrid===true) {
@@ -1532,8 +1567,10 @@ $.fn.jqGrid = function( pin ) {
1532
1567
  if(ts.p.gridview === true ) {
1533
1568
  fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0;
1534
1569
  if(ts.p.grouping) {
1535
- self.jqGrid('groupingRender',grpdata,ts.p.colModel.length);
1536
- grpdata = null;
1570
+ if(!locdata) {
1571
+ self.jqGrid('groupingRender', grpdata, ts.p.colModel.length, ts.p.page, rn);
1572
+ grpdata = null;
1573
+ }
1537
1574
  } else if(ts.p.treeGrid === true && fpos > 0) {
1538
1575
  $(ts.rows[fpos]).after(rowData.join(''));
1539
1576
  } else {
@@ -1592,12 +1629,20 @@ $.fn.jqGrid = function( pin ) {
1592
1629
  rd[ts.p.colModel[j+gi+si+ni].name] = $.jgrid.getAccessor(cur,rowReader[j]);
1593
1630
  }
1594
1631
  rd[locid] = $.jgrid.stripPref(ts.p.idPrefix, idr);
1632
+ if(ts.p.grouping) {
1633
+ groupingPrepare.call(self, rd, ir );
1634
+ }
1595
1635
  ts.p.data.push(rd);
1596
1636
  ts.p._index[rd[locid]] = ts.p.data.length-1;
1597
1637
  rd = {};
1598
1638
  }
1599
1639
  ir++;
1600
1640
  }
1641
+ if(ts.p.grouping) {
1642
+ ts.p.groupingView._locgr = true;
1643
+ self.jqGrid('groupingRender', grpdata, ts.p.colModel.length, ts.p.page, rn);
1644
+ grpdata = null;
1645
+ }
1601
1646
  }
1602
1647
  },
1603
1648
  addLocalData = function() {
@@ -1623,9 +1668,9 @@ $.fn.jqGrid = function( pin ) {
1623
1668
  } else {
1624
1669
  srcformat = newformat = this.datefmt || "Y-m-d";
1625
1670
  }
1626
- cmtypes[this.name] = {"stype": sorttype, "srcfmt": srcformat,"newfmt":newformat};
1671
+ cmtypes[this.name] = {"stype": sorttype, "srcfmt": srcformat,"newfmt":newformat, "sfunc": this.sortfunc || null};
1627
1672
  } else {
1628
- cmtypes[this.name] = {"stype": sorttype, "srcfmt":'',"newfmt":''};
1673
+ cmtypes[this.name] = {"stype": sorttype, "srcfmt":'',"newfmt":'', "sfunc": this.sortfunc || null};
1629
1674
  }
1630
1675
  if(ts.p.grouping ) {
1631
1676
  for(gin =0, lengrp = grpview.groupField.length; gin< lengrp; gin++) {
@@ -1744,14 +1789,14 @@ $.fn.jqGrid = function( pin ) {
1744
1789
  }
1745
1790
  if(ts.p.multiSort) {
1746
1791
  $.each(st,function(i){
1747
- query.orderBy(this, sto[i], cmtypes[this].stype, cmtypes[this].srcfmt);
1792
+ query.orderBy(this, sto[i], cmtypes[this].stype, cmtypes[this].srcfmt, cmtypes[this].sfunc);
1748
1793
  });
1749
1794
  } else {
1750
1795
  if (st && ts.p.sortorder && fndsort) {
1751
1796
  if(ts.p.sortorder.toUpperCase() === "DESC") {
1752
- query.orderBy(ts.p.sortname, "d", cmtypes[st].stype, cmtypes[st].srcfmt);
1797
+ query.orderBy(ts.p.sortname, "d", cmtypes[st].stype, cmtypes[st].srcfmt, cmtypes[st].sfunc);
1753
1798
  } else {
1754
- query.orderBy(ts.p.sortname, "a", cmtypes[st].stype, cmtypes[st].srcfmt);
1799
+ query.orderBy(ts.p.sortname, "a", cmtypes[st].stype, cmtypes[st].srcfmt, cmtypes[st].sfunc);
1755
1800
  }
1756
1801
  }
1757
1802
  }
@@ -1761,6 +1806,26 @@ $.fn.jqGrid = function( pin ) {
1761
1806
  page = parseInt(ts.p.page,10),
1762
1807
  totalpages = Math.ceil(total / recordsperpage),
1763
1808
  retresult = {};
1809
+ if((ts.p.search || ts.p.resetsearch) && ts.p.grouping && ts.p.groupingView._locgr) {
1810
+ ts.p.groupingView.groups =[];
1811
+ var j, grPrepare = $.jgrid.getMethod("groupingPrepare"), key, udc;
1812
+ if(ts.p.footerrow && ts.p.userDataOnFooter) {
1813
+ for (key in ts.p.userData) {
1814
+ if(ts.p.userData.hasOwnProperty(key)) {
1815
+ ts.p.userData[key] = 0;
1816
+ }
1817
+ }
1818
+ udc = true;
1819
+ }
1820
+ for(j=0; j<total; j++) {
1821
+ if(udc) {
1822
+ for(key in ts.p.userData){
1823
+ ts.p.userData[key] += parseFloat(queryResults[j][key] || 0);
1824
+ }
1825
+ }
1826
+ grPrepare.call($(ts),queryResults[j],j, recordsperpage );
1827
+ }
1828
+ }
1764
1829
  queryResults = queryResults.slice( (page-1)*recordsperpage , page*recordsperpage );
1765
1830
  query = null;
1766
1831
  cmtypes = null;
@@ -2105,6 +2170,9 @@ $.fn.jqGrid = function( pin ) {
2105
2170
  }
2106
2171
  });
2107
2172
  $("#first"+$.jgrid.jqID(tp)+", #prev"+$.jgrid.jqID(tp)+", #next"+$.jgrid.jqID(tp)+", #last"+$.jgrid.jqID(tp)).click( function() {
2173
+ if ($(this).hasClass("ui-state-disabled")) {
2174
+ return false;
2175
+ }
2108
2176
  var cp = intNum(ts.p.page,1),
2109
2177
  last = intNum(ts.p.lastpage,1), selclick = false,
2110
2178
  fp=true, pp=true, np=true,lp=true;
@@ -2758,12 +2826,12 @@ $.fn.jqGrid = function( pin ) {
2758
2826
  }
2759
2827
  if(hg) {$(grid.bDiv).hide();}
2760
2828
  grid.cDiv = document.createElement("div");
2761
- var arf = ts.p.hidegrid===true ? $("<a role='link' class='ui-jqgrid-titlebar-close HeaderButton' />").hover(
2829
+ var arf = ts.p.hidegrid===true ? $("<a role='link' class='ui-jqgrid-titlebar-close ui-corner-all HeaderButton' />").hover(
2762
2830
  function(){ arf.addClass('ui-state-hover');},
2763
2831
  function() {arf.removeClass('ui-state-hover');})
2764
2832
  .append("<span class='ui-icon ui-icon-circle-triangle-n'></span>").css((dir==="rtl"?"left":"right"),"0px") : "";
2765
- $(grid.cDiv).append(arf).append("<span class='ui-jqgrid-title"+(dir==="rtl" ? "-rtl" :"" )+"'>"+ts.p.caption+"</span>")
2766
- .addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix");
2833
+ $(grid.cDiv).append(arf).append("<span class='ui-jqgrid-title'>"+ts.p.caption+"</span>")
2834
+ .addClass("ui-jqgrid-titlebar ui-jqgrid-caption"+(dir==="rtl" ? "-rtl" :"" )+" ui-widget-header ui-corner-top ui-helper-clearfix");
2767
2835
  $(grid.cDiv).insertBefore(grid.hDiv);
2768
2836
  if( ts.p.toolbar[0] ) {
2769
2837
  grid.uDiv = document.createElement("div");
@@ -2883,7 +2951,14 @@ $.jgrid.extend({
2883
2951
  var row;
2884
2952
  this.each( function(){
2885
2953
  try {
2886
- row = this.rows.namedItem( rowid );
2954
+ //row = this.rows.namedItem( rowid );
2955
+ var i = this.rows.length;
2956
+ while(i--) {
2957
+ if( rowid.toString() === this.rows[i].id) {
2958
+ row = this.rows[i];
2959
+ break;
2960
+ }
2961
+ }
2887
2962
  } catch ( e ) {
2888
2963
  row = $(this.grid.bDiv).find( "#" + $.jgrid.jqID( rowid ));
2889
2964
  }
@@ -3018,6 +3093,7 @@ $.jgrid.extend({
3018
3093
  });
3019
3094
  t.setHeadCheckBox( false );
3020
3095
  t.p.selarrrow = [];
3096
+ t.p.selrow = null;
3021
3097
  }
3022
3098
  if(t.p.cellEdit === true) {
3023
3099
  if(parseInt(t.p.iCol,10)>=0 && parseInt(t.p.iRow,10)>=0) {
@@ -3146,7 +3222,7 @@ $.jgrid.extend({
3146
3222
  }
3147
3223
  }
3148
3224
  if(success) {
3149
- if(cp === 'string') {$(ind).addClass(cssp);} else if(cp === 'object') {$(ind).css(cssp);}
3225
+ if(cp === 'string') {$(ind).addClass(cssp);} else if(cssp !== null && cp === 'object') {$(ind).css(cssp);}
3150
3226
  $(t).triggerHandler("jqGridAfterGridComplete");
3151
3227
  }
3152
3228
  });
@@ -3288,7 +3364,7 @@ $.jgrid.extend({
3288
3364
  }
3289
3365
  return true;
3290
3366
  }
3291
- if(action === undefined) { action = "get"; }
3367
+ if(action == undefined) { action = "get"; }
3292
3368
  if(typeof format !== "boolean") { format = true; }
3293
3369
  action = action.toLowerCase();
3294
3370
  this.each(function(){
@@ -3867,6 +3943,9 @@ $.jgrid.extend({
3867
3943
  }
3868
3944
  if ( idx !== -1 ){
3869
3945
  var sort = $t.p.colModel[idx].sortable;
3946
+ if(!sobj) {
3947
+ sobj = $t.grid.headers[idx].el;
3948
+ }
3870
3949
  if ( typeof sort !== 'boolean' ) { sort = true; }
3871
3950
  if ( typeof reload !=='boolean' ) { reload = false; }
3872
3951
  if ( sort ) { $t.sortData("jqgh_"+$t.p.id+"_" + colname, idx, reload, sor, sobj); }
@@ -3876,7 +3955,9 @@ $.jgrid.extend({
3876
3955
  clearBeforeUnload : function () {
3877
3956
  return this.each(function(){
3878
3957
  var grid = this.grid;
3879
- grid.emptyRows.call(this, true, true); // this work quick enough and reduce the size of memory leaks if we have someone
3958
+ if ($.isFunction(grid.emptyRows)) {
3959
+ grid.emptyRows.call(this, true, true); // this work quick enough and reduce the size of memory leaks if we have someone
3960
+ }
3880
3961
 
3881
3962
  $(document).unbind("mouseup.jqGrid" + this.p.id );
3882
3963
  $(grid.hDiv).unbind("mousemove"); // TODO add namespace
@@ -3909,6 +3990,7 @@ $.jgrid.extend({
3909
3990
  this.formatter = null;
3910
3991
  this.addXmlData = null;
3911
3992
  this.addJSONData = null;
3993
+ this.grid = null;
3912
3994
  });
3913
3995
  },
3914
3996
  GridDestroy : function () {
@@ -3929,7 +4011,7 @@ $.jgrid.extend({
3929
4011
  if ( !this.grid ) {return;}
3930
4012
  var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')};
3931
4013
  if (this.p.pager) {
3932
- $(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
4014
+ $(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager ui-corner-bottom");
3933
4015
  }
3934
4016
  var newtable = document.createElement('table');
3935
4017
  $(newtable).attr({id:defgrid.id});
@@ -3993,7 +4075,7 @@ $.jgrid.extend({
3993
4075
  groupOp: 'AND',
3994
4076
  defaultSearch : "bw",
3995
4077
  searchOperators : false,
3996
- operandTitle : "Click to select search operation.",
4078
+ resetIcon : "x",
3997
4079
  operands : { "eq" :"==", "ne":"!","lt":"<","le":"<=","gt":">","ge":">=","bw":"^","bn":"!^","in":"=","ni":"!=","ew":"|","en":"!@","cn":"~","nc":"!~","nu":"#","nn":"!#"}
3998
4080
  }, $.jgrid.search , p || {});
3999
4081
  return this.each(function(){
@@ -4081,7 +4163,7 @@ $.jgrid.extend({
4081
4163
  }
4082
4164
  break;
4083
4165
  case 'text':
4084
- $elem.val(v);
4166
+ $elem.val(v || "");
4085
4167
  if(v !== undefined) {
4086
4168
  sdata[nm] = v;
4087
4169
  j++;
@@ -4093,12 +4175,13 @@ $.jgrid.extend({
4093
4175
  break;
4094
4176
  case 'custom':
4095
4177
  if ($.isFunction(this.searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN") {
4096
- this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "set", v);
4178
+ this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "set", v || "");
4097
4179
  }
4098
4180
  break;
4099
4181
  }
4100
4182
  });
4101
4183
  var sd = j>0 ? true : false;
4184
+ $t.p.resetsearch = true;
4102
4185
  if(p.stringResult === true || $t.p.datatype === "local") {
4103
4186
  var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
4104
4187
  var gi=0;
@@ -4228,7 +4311,10 @@ $.jgrid.extend({
4228
4311
  soptions.clearSearch = true;
4229
4312
  }
4230
4313
  if(soptions.clearSearch) {
4231
- $("td:eq(2)",stbl).append("<a title='Clear Search Value' style='padding-right: 0.3em;padding-left: 0.3em;' class='clearsearchclass'>x</a>");
4314
+ var csv = p.resetTitle || 'Clear Search Value';
4315
+ $("td:eq(2)",stbl).append("<a title='"+csv+"' style='padding-right: 0.3em;padding-left: 0.3em;' class='clearsearchclass'>"+p.resetIcon+"</a>");
4316
+ } else {
4317
+ $("td:eq(2)", stbl).hide();
4232
4318
  }
4233
4319
  switch (this.stype)
4234
4320
  {
@@ -4543,7 +4629,7 @@ $.jgrid.extend({
4543
4629
  // The text will be over the cVisibleColumns columns
4544
4630
  $colHeader = $('<th>').attr({role: "columnheader"})
4545
4631
  .addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
4546
- .css({'height':'22px', 'border-top': '0px none'})
4632
+ .css({'height':'22px', 'border-top': '0 none'})
4547
4633
  .html(titleText);
4548
4634
  if(cVisibleColumns > 0) {
4549
4635
  $colHeader.attr("colspan", String(cVisibleColumns));
@@ -4569,7 +4655,7 @@ $.jgrid.extend({
4569
4655
  } else {
4570
4656
  $('<th>', {role: "columnheader"})
4571
4657
  .addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
4572
- .css({"display": cmi.hidden ? 'none' : '', 'border-top': '0px none'})
4658
+ .css({"display": cmi.hidden ? 'none' : '', 'border-top': '0 none'})
4573
4659
  .insertBefore($th);
4574
4660
  $tr.append(th);
4575
4661
  }
@@ -4617,7 +4703,7 @@ $.jgrid.extend({
4617
4703
  if ( !this.grid ) {return;}
4618
4704
  var $t = this, cm = $t.p.colModel,i=0, len = cm.length, maxfrozen = -1, frozen= false;
4619
4705
  // TODO treeGrid and grouping Support
4620
- if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll || $t.p.grouping )
4706
+ if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll )
4621
4707
  {
4622
4708
  return;
4623
4709
  }
@@ -5519,18 +5605,7 @@ var xmlJsonClass = {
5519
5605
  cm = p.colModel[$.jgrid.getCellIndex(this)],
5520
5606
  $actionsDiv = cm.frozen ? $("tr#"+rid+" td:eq("+$.jgrid.getCellIndex(this)+") > div",$grid) :$(this).parent(),
5521
5607
  op = {
5522
- keys: false,
5523
- onEdit: null,
5524
- onSuccess: null,
5525
- afterSave: null,
5526
- onError: null,
5527
- afterRestore: null,
5528
- extraparam: {},
5529
- url: null,
5530
- restoreAfterError: true,
5531
- mtype: "POST",
5532
- delOptions: {},
5533
- editOptions: {}
5608
+ extraparam: {}
5534
5609
  },
5535
5610
  saverow = function(rowid, res) {
5536
5611
  if($.isFunction(op.afterSave)) { op.afterSave.call($t, rowid, res); }
@@ -6786,13 +6861,10 @@ $.fn.jqFilter = function( arg ) {
6786
6861
  $(".data",trpar).empty().append( elm );
6787
6862
  $.jgrid.bindEv.call($t, elm, cm.searchoptions);
6788
6863
  $(".input-elm",trpar).bind('change',function( e ) {
6789
- var tmo = $(this).hasClass("ui-autocomplete-input") ? 200 :0;
6790
- setTimeout(function(){
6791
- var elem = e.target;
6792
- rule.data = elem.nodeName.toUpperCase() === "SPAN" && cm.searchoptions && $.isFunction(cm.searchoptions.custom_value) ?
6793
- cm.searchoptions.custom_value.call($t, $(elem).children(".customelement:first"), 'get') : elem.value;
6794
- that.onchange(); // signals that the filter has changed
6795
- }, tmo);
6864
+ var elem = e.target;
6865
+ rule.data = elem.nodeName.toUpperCase() === "SPAN" && cm.searchoptions && $.isFunction(cm.searchoptions.custom_value) ?
6866
+ cm.searchoptions.custom_value.call($t, $(elem).children(".customelement:first"), 'get') : elem.value;
6867
+ that.onchange(); // signals that the filter has changed
6796
6868
  });
6797
6869
  setTimeout(function(){ //IE, Opera, Chrome
6798
6870
  rule.data = $(elm).val();
@@ -6962,7 +7034,7 @@ $.fn.jqFilter = function( arg ) {
6962
7034
  break;
6963
7035
  }
6964
7036
  }
6965
- if (cm === undefined) { return ""; }
7037
+ if (cm == undefined) { return ""; }
6966
7038
  val = rule.data;
6967
7039
  if(opC === 'bw' || opC === 'bn') { val = val+"%"; }
6968
7040
  if(opC === 'ew' || opC === 'en') { val = "%"+val; }
@@ -7315,11 +7387,11 @@ $.jgrid.extend({
7315
7387
  !$target.hasClass('add-group') && !$target.hasClass('add-rule') &&
7316
7388
  !$target.hasClass('delete-group') && !$target.hasClass('delete-rule') &&
7317
7389
  (!$target.hasClass("fm-button") || !$target.is("[id$=_query]"))) {
7318
- $("#"+fid+"_search").focus().click();
7390
+ $("#"+fid+"_search").click();
7319
7391
  return false;
7320
7392
  }
7321
7393
  if (p.closeOnEscape && e.which === 27) { // 27 === $.ui.keyCode.ESCAPE
7322
- $("#"+$.jgrid.jqID(IDs.modalhead)).find(".ui-jqdialog-titlebar-close").focus().click();
7394
+ $("#"+$.jgrid.jqID(IDs.modalhead)).find(".ui-jqdialog-titlebar-close").click();
7323
7395
  return false;
7324
7396
  }
7325
7397
  });
@@ -7335,8 +7407,8 @@ $.jgrid.extend({
7335
7407
  p.stringResult = p.multipleSearch;
7336
7408
  }
7337
7409
  $("#"+fid+"_search").bind('click', function(){
7338
- var fl = $("#"+fid),
7339
- sdata={}, res,
7410
+ var fl = $("#"+fid), sdata={}, res, filters;
7411
+ fl.find(".input-elm:focus").change();
7340
7412
  filters = fl.jqFilter('filterData');
7341
7413
  if(p.errorcheck) {
7342
7414
  fl[0].hideError();
@@ -7392,6 +7464,7 @@ $.jgrid.extend({
7392
7464
  var sdata={},
7393
7465
  fl = $("#"+fid);
7394
7466
  $t.p.search = false;
7467
+ $t.p.resetsearch = true;
7395
7468
  if(p.multipleSearch===false) {
7396
7469
  sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = "";
7397
7470
  } else {
@@ -7495,8 +7568,10 @@ $.jgrid.extend({
7495
7568
  p.caption=rp_ge[$t.p.id].editCaption;
7496
7569
  frmoper = "edit";
7497
7570
  }
7498
- if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {
7499
- $("#"+$.jgrid.jqID(IDs.themodal)).remove();
7571
+ if(!p.recreateForm) {
7572
+ if( $($t).data("formProp") ) {
7573
+ $.extend(rp_ge[$(this)[0].p.id], $($t).data("formProp"));
7574
+ }
7500
7575
  }
7501
7576
  var closeovrl = true;
7502
7577
  if(p.checkOnUpdate && p.jqModal && !p.modal) {
@@ -8027,298 +8102,260 @@ $.jgrid.extend({
8027
8102
  return [pos,rowsInGrid];
8028
8103
  }
8029
8104
 
8030
- if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
8031
- showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+$.jgrid.jqID(frmgr)), frmoper]);
8032
- if(showFrm === undefined) {
8033
- showFrm = true;
8034
- }
8035
- if(showFrm && onBeforeInit) {
8036
- showFrm = onBeforeInit.call($t,$("#"+frmgr), frmoper);
8037
- }
8038
- if(showFrm === false) {return;}
8039
- restoreInline();
8040
- $(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
8041
- $("#FormError",frmtb).hide();
8042
- if(rp_ge[$t.p.id].topinfo) {
8043
- $(".topinfo",frmtb).html(rp_ge[$t.p.id].topinfo);
8044
- $(".tinfo",frmtb).show();
8045
- } else {
8046
- $(".tinfo",frmtb).hide();
8047
- }
8048
- if(rp_ge[$t.p.id].bottominfo) {
8049
- $(".bottominfo",frmtb+"_2").html(rp_ge[$t.p.id].bottominfo);
8050
- $(".binfo",frmtb+"_2").show();
8051
- } else {
8052
- $(".binfo",frmtb+"_2").hide();
8053
- }
8054
- // filldata
8055
- fillData(rowid,$t,frmgr);
8056
- ///
8057
- if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {
8058
- $("#pData, #nData",frmtb+"_2").hide();
8059
- } else {
8060
- $("#pData, #nData",frmtb+"_2").show();
8061
- }
8062
- if(rp_ge[$t.p.id].processing===true) {
8063
- rp_ge[$t.p.id].processing=false;
8064
- $("#sData", frmtb+"_2").removeClass('ui-state-active');
8065
- }
8066
- if($("#"+frmgr).data("disabled")===true) {
8067
- $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8068
- $("#"+frmgr).data("disabled",false);
8069
- }
8070
- $($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
8071
- if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper); }
8072
- $("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
8073
- $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal, overlayClass : p.overlayClass});
8074
- if(!closeovrl) {
8075
- $("." + $.jgrid.jqID(p.overlayClass)).click(function(){
8076
- if(!checkUpdates()) {return false;}
8077
- $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
8078
- return false;
8079
- });
8080
- }
8081
- $($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
8082
- if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); }
8083
- } else {
8084
- var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px",
8085
- dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px",
8086
- frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' onSubmit='return false;' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>").data("disabled",false),
8087
- tbl = $("<table id='"+frmtborg+"' class='EditTable' cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>");
8088
- showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+frmgr), frmoper]);
8089
- if(showFrm === undefined) {
8090
- showFrm = true;
8091
- }
8092
- if(showFrm && onBeforeInit) {
8093
- showFrm = onBeforeInit.call($t,$("#"+frmgr),frmoper);
8094
- }
8095
- if(showFrm === false) {return;}
8096
- restoreInline();
8097
- $($t.p.colModel).each( function() {
8098
- var fmto = this.formoptions;
8099
- maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
8100
- maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
8105
+ var dh = isNaN(rp_ge[$(this)[0].p.id].dataheight) ? rp_ge[$(this)[0].p.id].dataheight : rp_ge[$(this)[0].p.id].dataheight+"px",
8106
+ dw = isNaN(rp_ge[$(this)[0].p.id].datawidth) ? rp_ge[$(this)[0].p.id].datawidth : rp_ge[$(this)[0].p.id].datawidth+"px",
8107
+ frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' onSubmit='return false;' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>").data("disabled",false),
8108
+ tbl = $("<table id='"+frmtborg+"' class='EditTable' cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>");
8109
+ showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+frmgr), frmoper]);
8110
+ if(showFrm === undefined) {
8111
+ showFrm = true;
8112
+ }
8113
+ if(showFrm && onBeforeInit) {
8114
+ showFrm = onBeforeInit.call($t,$("#"+frmgr),frmoper);
8115
+ }
8116
+ if(showFrm === false) {return;}
8117
+ restoreInline();
8118
+ $($t.p.colModel).each( function() {
8119
+ var fmto = this.formoptions;
8120
+ maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
8121
+ maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
8122
+ });
8123
+ $(frm).append(tbl);
8124
+ var flr = $("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='"+(maxCols*2)+"'></td></tr>");
8125
+ flr[0].rp = 0;
8126
+ $(tbl).append(flr);
8127
+ //topinfo
8128
+ flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='"+(maxCols*2)+"'>"+rp_ge[$t.p.id].topinfo+"</td></tr>");
8129
+ flr[0].rp = 0;
8130
+ $(tbl).append(flr);
8131
+ // set the id.
8132
+ // use carefull only to change here colproperties.
8133
+ // create data
8134
+ var rtlb = $t.p.direction === "rtl" ? true :false,
8135
+ bp = rtlb ? "nData" : "pData",
8136
+ bn = rtlb ? "pData" : "nData";
8137
+ createData(rowid,$t,tbl,maxCols);
8138
+ // buttons at footer
8139
+ var bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
8140
+ bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
8141
+ bS ="<a id='sData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
8142
+ bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
8143
+ var bt = "<table border='0' cellspacing='0' cellpadding='0' class='EditTable' id='"+frmtborg+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr id='Act_Buttons'><td class='navButton'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bS+bC+"</td></tr>";
8144
+ bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>"+rp_ge[$t.p.id].bottominfo+"</td></tr>";
8145
+ bt += "</tbody></table>";
8146
+ if(maxRows > 0) {
8147
+ var sd=[];
8148
+ $.each($(tbl)[0].rows,function(i,r){
8149
+ sd[i] = r;
8101
8150
  });
8102
- $(frm).append(tbl);
8103
- var flr = $("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='"+(maxCols*2)+"'></td></tr>");
8104
- flr[0].rp = 0;
8105
- $(tbl).append(flr);
8106
- //topinfo
8107
- flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='"+(maxCols*2)+"'>"+rp_ge[$t.p.id].topinfo+"</td></tr>");
8108
- flr[0].rp = 0;
8109
- $(tbl).append(flr);
8110
- // set the id.
8111
- // use carefull only to change here colproperties.
8112
- // create data
8113
- var rtlb = $t.p.direction === "rtl" ? true :false,
8114
- bp = rtlb ? "nData" : "pData",
8115
- bn = rtlb ? "pData" : "nData";
8116
- createData(rowid,$t,tbl,maxCols);
8117
- // buttons at footer
8118
- var bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
8119
- bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
8120
- bS ="<a id='sData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
8121
- bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
8122
- var bt = "<table border='0' cellspacing='0' cellpadding='0' class='EditTable' id='"+frmtborg+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr id='Act_Buttons'><td class='navButton'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bS+bC+"</td></tr>";
8123
- bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>"+rp_ge[$t.p.id].bottominfo+"</td></tr>";
8124
- bt += "</tbody></table>";
8125
- if(maxRows > 0) {
8126
- var sd=[];
8127
- $.each($(tbl)[0].rows,function(i,r){
8128
- sd[i] = r;
8129
- });
8130
- sd.sort(function(a,b){
8131
- if(a.rp > b.rp) {return 1;}
8132
- if(a.rp < b.rp) {return -1;}
8133
- return 0;
8134
- });
8135
- $.each(sd, function(index, row) {
8136
- $('tbody',tbl).append(row);
8137
- });
8138
- }
8139
- p.gbox = "#gbox_"+$.jgrid.jqID(gID);
8140
- var cle = false;
8141
- if(p.closeOnEscape===true){
8142
- p.closeOnEscape = false;
8143
- cle = true;
8144
- }
8145
- var tms = $("<div></div>").append(frm).append(bt);
8146
- $.jgrid.createModal(IDs,tms,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
8147
- if(rtlb) {
8148
- $("#pData, #nData",frmtb+"_2").css("float","right");
8149
- $(".EditButton",frmtb+"_2").css("text-align","left");
8150
- }
8151
- if(rp_ge[$t.p.id].topinfo) {$(".tinfo",frmtb).show();}
8152
- if(rp_ge[$t.p.id].bottominfo) {$(".binfo",frmtb+"_2").show();}
8153
- tms = null;bt=null;
8154
- $("#"+$.jgrid.jqID(IDs.themodal)).keydown( function( e ) {
8155
- var wkey = e.target;
8156
- if ($("#"+frmgr).data("disabled")===true ) {return false;}//??
8157
- if(rp_ge[$t.p.id].savekey[0] === true && e.which === rp_ge[$t.p.id].savekey[1]) { // save
8158
- if(wkey.tagName !== "TEXTAREA") {
8159
- $("#sData", frmtb+"_2").trigger("click");
8160
- return false;
8161
- }
8162
- }
8163
- if(e.which === 27) {
8164
- if(!checkUpdates()) {return false;}
8165
- if(cle) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
8166
- return false;
8167
- }
8168
- if(rp_ge[$t.p.id].navkeys[0]===true) {
8169
- if($("#id_g",frmtb).val() === "_empty") {return true;}
8170
- if(e.which === rp_ge[$t.p.id].navkeys[1]){ //up
8171
- $("#pData", frmtb+"_2").trigger("click");
8172
- return false;
8173
- }
8174
- if(e.which === rp_ge[$t.p.id].navkeys[2]){ //down
8175
- $("#nData", frmtb+"_2").trigger("click");
8176
- return false;
8177
- }
8178
- }
8151
+ sd.sort(function(a,b){
8152
+ if(a.rp > b.rp) {return 1;}
8153
+ if(a.rp < b.rp) {return -1;}
8154
+ return 0;
8179
8155
  });
8180
- if(p.checkOnUpdate) {
8181
- $("a.ui-jqdialog-titlebar-close span","#"+$.jgrid.jqID(IDs.themodal)).removeClass("jqmClose");
8182
- $("a.ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.themodal)).unbind("click")
8183
- .click(function(){
8184
- if(!checkUpdates()) {return false;}
8185
- $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
8156
+ $.each(sd, function(index, row) {
8157
+ $('tbody',tbl).append(row);
8158
+ });
8159
+ }
8160
+ p.gbox = "#gbox_"+$.jgrid.jqID(gID);
8161
+ var cle = false;
8162
+ if(p.closeOnEscape===true){
8163
+ p.closeOnEscape = false;
8164
+ cle = true;
8165
+ }
8166
+ var tms = $("<div></div>").append(frm).append(bt);
8167
+ $.jgrid.createModal(IDs,tms, rp_ge[$(this)[0].p.id] ,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
8168
+ if(rtlb) {
8169
+ $("#pData, #nData",frmtb+"_2").css("float","right");
8170
+ $(".EditButton",frmtb+"_2").css("text-align","left");
8171
+ }
8172
+ if(rp_ge[$t.p.id].topinfo) {$(".tinfo",frmtb).show();}
8173
+ if(rp_ge[$t.p.id].bottominfo) {$(".binfo",frmtb+"_2").show();}
8174
+ tms = null;bt=null;
8175
+ $("#"+$.jgrid.jqID(IDs.themodal)).keydown( function( e ) {
8176
+ var wkey = e.target;
8177
+ if ($("#"+frmgr).data("disabled")===true ) {return false;}//??
8178
+ if(rp_ge[$t.p.id].savekey[0] === true && e.which === rp_ge[$t.p.id].savekey[1]) { // save
8179
+ if(wkey.tagName !== "TEXTAREA") {
8180
+ $("#sData", frmtb+"_2").trigger("click");
8186
8181
  return false;
8187
- });
8182
+ }
8188
8183
  }
8189
- p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon);
8190
- p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
8191
- // beforeinitdata after creation of the form
8192
- if(p.saveicon[0]===true) {
8193
- $("#sData",frmtb+"_2").addClass(p.saveicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8194
- .append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
8195
- }
8196
- if(p.closeicon[0]===true) {
8197
- $("#cData",frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8198
- .append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
8199
- }
8200
- if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
8201
- bS ="<a id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bYes+"</a>";
8202
- bN ="<a id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bNo+"</a>";
8203
- bC ="<a id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bExit+"</a>";
8204
- var zI = p.zIndex || 999;zI ++;
8205
- $("<div class='"+ p.overlayClass+" jqgrid-overlay confirm' style='z-index:"+zI+";display:none;'>&#160;"+"</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:"+(zI+1)+"'>"+p.saveData+"<br/><br/>"+bS+bN+bC+"</div>").insertAfter("#"+frmgr);
8206
- $("#sNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8207
- postIt();
8208
- $("#"+frmgr).data("disabled",false);
8209
- $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8210
- return false;
8211
- });
8212
- $("#nNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8213
- $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8214
- $("#"+frmgr).data("disabled",false);
8215
- setTimeout(function(){$(":input:visible","#"+frmgr)[0].focus();},0);
8216
- return false;
8217
- });
8218
- $("#cNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8219
- $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8220
- $("#"+frmgr).data("disabled",false);
8221
- $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
8222
- return false;
8223
- });
8184
+ if(e.which === 27) {
8185
+ if(!checkUpdates()) {return false;}
8186
+ if(cle) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
8187
+ return false;
8224
8188
  }
8225
- // here initform - only once
8226
- $($t).triggerHandler("jqGridAddEditInitializeForm", [$("#"+frmgr), frmoper]);
8227
- if(onInitializeForm) {onInitializeForm.call($t,$("#"+frmgr), frmoper);}
8228
- if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {$("#pData,#nData",frmtb+"_2").hide();} else {$("#pData,#nData",frmtb+"_2").show();}
8229
- $($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
8230
- if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper);}
8231
- $("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
8232
- $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, overlay: p.overlay,modal:p.modal, overlayClass: p.overlayClass});
8233
- if(!closeovrl) {
8234
- $("." + $.jgrid.jqID(p.overlayClass)).click(function(){
8235
- if(!checkUpdates()) {return false;}
8236
- $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
8189
+ if(rp_ge[$t.p.id].navkeys[0]===true) {
8190
+ if($("#id_g",frmtb).val() === "_empty") {return true;}
8191
+ if(e.which === rp_ge[$t.p.id].navkeys[1]){ //up
8192
+ $("#pData", frmtb+"_2").trigger("click");
8237
8193
  return false;
8238
- });
8239
- }
8240
- $($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
8241
- if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); }
8242
- $(".fm-button","#"+$.jgrid.jqID(IDs.themodal)).hover(
8243
- function(){$(this).addClass('ui-state-hover');},
8244
- function(){$(this).removeClass('ui-state-hover');}
8245
- );
8246
- $("#sData", frmtb+"_2").click(function(){
8247
- postdata = {};
8248
- $("#FormError",frmtb).hide();
8249
- // all depend on ret array
8250
- //ret[0] - succes
8251
- //ret[1] - msg if not succes
8252
- //ret[2] - the id that will be set if reload after submit false
8253
- getFormData();
8254
- if(postdata[$t.p.id+"_id"] === "_empty") {postIt();}
8255
- else if(p.checkOnSubmit===true ) {
8256
- diff = compareData(postdata,rp_ge[$t.p.id]._savedData);
8257
- if(diff) {
8258
- $("#"+frmgr).data("disabled",true);
8259
- $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).show();
8260
- } else {
8261
- postIt();
8262
- }
8263
- } else {
8264
- postIt();
8265
8194
  }
8266
- return false;
8267
- });
8268
- $("#cData", frmtb+"_2").click(function(){
8195
+ if(e.which === rp_ge[$t.p.id].navkeys[2]){ //down
8196
+ $("#nData", frmtb+"_2").trigger("click");
8197
+ return false;
8198
+ }
8199
+ }
8200
+ });
8201
+ if(p.checkOnUpdate) {
8202
+ $("a.ui-jqdialog-titlebar-close span","#"+$.jgrid.jqID(IDs.themodal)).removeClass("jqmClose");
8203
+ $("a.ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.themodal)).unbind("click")
8204
+ .click(function(){
8269
8205
  if(!checkUpdates()) {return false;}
8270
8206
  $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
8271
8207
  return false;
8272
8208
  });
8273
- $("#nData", frmtb+"_2").click(function(){
8274
- if(!checkUpdates()) {return false;}
8275
- $("#FormError",frmtb).hide();
8276
- var npos = getCurrPos();
8277
- npos[0] = parseInt(npos[0],10);
8278
- if(npos[0] !== -1 && npos[1][npos[0]+1]) {
8279
- $($t).triggerHandler("jqGridAddEditClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
8280
- var nposret;
8281
- if($.isFunction(p.onclickPgButtons)) {
8282
- nposret = p.onclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]]);
8283
- if( nposret !== undefined && nposret === false ) {return false;}
8284
- }
8285
- if( $("#"+$.jgrid.jqID(npos[1][npos[0]+1])).hasClass('ui-state-disabled')) {return false;}
8286
- fillData(npos[1][npos[0]+1],$t,frmgr);
8287
- $($t).jqGrid("setSelection",npos[1][npos[0]+1]);
8288
- $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
8289
- if($.isFunction(p.afterclickPgButtons)) {
8290
- p.afterclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]+1]);
8291
- }
8292
- updateNav(npos[0]+1,npos);
8293
- }
8209
+ }
8210
+ p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon);
8211
+ p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
8212
+ // beforeinitdata after creation of the form
8213
+ if(p.saveicon[0]===true) {
8214
+ $("#sData",frmtb+"_2").addClass(p.saveicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8215
+ .append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
8216
+ }
8217
+ if(p.closeicon[0]===true) {
8218
+ $("#cData",frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8219
+ .append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
8220
+ }
8221
+ if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
8222
+ bS ="<a id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bYes+"</a>";
8223
+ bN ="<a id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bNo+"</a>";
8224
+ bC ="<a id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bExit+"</a>";
8225
+ var zI = p.zIndex || 999;zI ++;
8226
+ $("<div class='"+ p.overlayClass+" jqgrid-overlay confirm' style='z-index:"+zI+";display:none;'>&#160;"+"</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:"+(zI+1)+"'>"+p.saveData+"<br/><br/>"+bS+bN+bC+"</div>").insertAfter("#"+frmgr);
8227
+ $("#sNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8228
+ postIt();
8229
+ $("#"+frmgr).data("disabled",false);
8230
+ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8294
8231
  return false;
8295
8232
  });
8296
- $("#pData", frmtb+"_2").click(function(){
8233
+ $("#nNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8234
+ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8235
+ $("#"+frmgr).data("disabled",false);
8236
+ setTimeout(function(){$(":input:visible","#"+frmgr)[0].focus();},0);
8237
+ return false;
8238
+ });
8239
+ $("#cNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
8240
+ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
8241
+ $("#"+frmgr).data("disabled",false);
8242
+ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
8243
+ return false;
8244
+ });
8245
+ }
8246
+ // here initform - only once
8247
+ $($t).triggerHandler("jqGridAddEditInitializeForm", [$("#"+frmgr), frmoper]);
8248
+ if(onInitializeForm) {onInitializeForm.call($t,$("#"+frmgr), frmoper);}
8249
+ if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {$("#pData,#nData",frmtb+"_2").hide();} else {$("#pData,#nData",frmtb+"_2").show();}
8250
+ $($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
8251
+ if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper);}
8252
+ $("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
8253
+ $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{
8254
+ gbox:"#gbox_"+$.jgrid.jqID(gID),
8255
+ jqm:p.jqModal,
8256
+ overlay: p.overlay,
8257
+ modal:p.modal,
8258
+ overlayClass: p.overlayClass,
8259
+ onHide : function(h) {
8260
+ $($t).data("formProp", {
8261
+ top:parseFloat($(h.w).css("top")),
8262
+ left : parseFloat($(h.w).css("left")),
8263
+ width : $(h.w).width(),
8264
+ height : $(h.w).height(),
8265
+ dataheight : $("#"+frmgr).height(),
8266
+ datawidth: $("#"+frmgr).width()
8267
+ });
8268
+ h.w.remove();
8269
+ if(h.o) {h.o.remove();}
8270
+ }
8271
+ });
8272
+ if(!closeovrl) {
8273
+ $("." + $.jgrid.jqID(p.overlayClass)).click(function(){
8297
8274
  if(!checkUpdates()) {return false;}
8298
- $("#FormError",frmtb).hide();
8299
- var ppos = getCurrPos();
8300
- if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
8301
- $($t).triggerHandler("jqGridAddEditClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
8302
- var pposret;
8303
- if($.isFunction(p.onclickPgButtons)) {
8304
- pposret = p.onclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]]);
8305
- if( pposret !== undefined && pposret === false ) {return false;}
8306
- }
8307
- if( $("#"+$.jgrid.jqID(ppos[1][ppos[0]-1])).hasClass('ui-state-disabled')) {return false;}
8308
- fillData(ppos[1][ppos[0]-1],$t,frmgr);
8309
- $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
8310
- $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
8311
- if($.isFunction(p.afterclickPgButtons)) {
8312
- p.afterclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
8313
- }
8314
- updateNav(ppos[0]-1,ppos);
8315
- }
8275
+ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
8316
8276
  return false;
8317
8277
  });
8318
8278
  }
8279
+ $(".fm-button","#"+$.jgrid.jqID(IDs.themodal)).hover(
8280
+ function(){$(this).addClass('ui-state-hover');},
8281
+ function(){$(this).removeClass('ui-state-hover');}
8282
+ );
8283
+ $("#sData", frmtb+"_2").click(function(){
8284
+ postdata = {};
8285
+ $("#FormError",frmtb).hide();
8286
+ // all depend on ret array
8287
+ //ret[0] - succes
8288
+ //ret[1] - msg if not succes
8289
+ //ret[2] - the id that will be set if reload after submit false
8290
+ getFormData();
8291
+ if(postdata[$t.p.id+"_id"] === "_empty") {postIt();}
8292
+ else if(p.checkOnSubmit===true ) {
8293
+ diff = compareData(postdata,rp_ge[$t.p.id]._savedData);
8294
+ if(diff) {
8295
+ $("#"+frmgr).data("disabled",true);
8296
+ $(".confirm","#"+$.jgrid.jqID(IDs.themodal)).show();
8297
+ } else {
8298
+ postIt();
8299
+ }
8300
+ } else {
8301
+ postIt();
8302
+ }
8303
+ return false;
8304
+ });
8305
+ $("#cData", frmtb+"_2").click(function(){
8306
+ if(!checkUpdates()) {return false;}
8307
+ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
8308
+ return false;
8309
+ });
8310
+ $("#nData", frmtb+"_2").click(function(){
8311
+ if(!checkUpdates()) {return false;}
8312
+ $("#FormError",frmtb).hide();
8313
+ var npos = getCurrPos();
8314
+ npos[0] = parseInt(npos[0],10);
8315
+ if(npos[0] !== -1 && npos[1][npos[0]+1]) {
8316
+ $($t).triggerHandler("jqGridAddEditClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
8317
+ var nposret;
8318
+ if($.isFunction(p.onclickPgButtons)) {
8319
+ nposret = p.onclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]]);
8320
+ if( nposret !== undefined && nposret === false ) {return false;}
8321
+ }
8322
+ if( $("#"+$.jgrid.jqID(npos[1][npos[0]+1])).hasClass('ui-state-disabled')) {return false;}
8323
+ fillData(npos[1][npos[0]+1],$t,frmgr);
8324
+ $($t).jqGrid("setSelection",npos[1][npos[0]+1]);
8325
+ $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
8326
+ if($.isFunction(p.afterclickPgButtons)) {
8327
+ p.afterclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]+1]);
8328
+ }
8329
+ updateNav(npos[0]+1,npos);
8330
+ }
8331
+ return false;
8332
+ });
8333
+ $("#pData", frmtb+"_2").click(function(){
8334
+ if(!checkUpdates()) {return false;}
8335
+ $("#FormError",frmtb).hide();
8336
+ var ppos = getCurrPos();
8337
+ if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
8338
+ $($t).triggerHandler("jqGridAddEditClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
8339
+ var pposret;
8340
+ if($.isFunction(p.onclickPgButtons)) {
8341
+ pposret = p.onclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]]);
8342
+ if( pposret !== undefined && pposret === false ) {return false;}
8343
+ }
8344
+ if( $("#"+$.jgrid.jqID(ppos[1][ppos[0]-1])).hasClass('ui-state-disabled')) {return false;}
8345
+ fillData(ppos[1][ppos[0]-1],$t,frmgr);
8346
+ $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
8347
+ $($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
8348
+ if($.isFunction(p.afterclickPgButtons)) {
8349
+ p.afterclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
8350
+ }
8351
+ updateNav(ppos[0]-1,ppos);
8352
+ }
8353
+ return false;
8354
+ });
8355
+ $($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
8356
+ if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); }
8319
8357
  var posInit =getCurrPos();
8320
8358
  updateNav(posInit[0],posInit);
8321
-
8322
8359
  });
8323
8360
  },
8324
8361
  viewGridRow : function(rowid, p){
@@ -8355,8 +8392,10 @@ $.jgrid.extend({
8355
8392
  onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
8356
8393
  showFrm = true,
8357
8394
  maxCols = 1, maxRows=0;
8358
- if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {
8359
- $("#"+$.jgrid.jqID(IDs.themodal)).remove();
8395
+ if(!p.recreateForm) {
8396
+ if( $($t).data("viewProp") ) {
8397
+ $.extend(rp_ge[$(this)[0].p.id], $($t).data("viewProp"));
8398
+ }
8360
8399
  }
8361
8400
  function focusaref(){ //Sfari 3 issues
8362
8401
  if(rp_ge[$t.p.id].closeOnEscape===true || rp_ge[$t.p.id].navkeys[0]===true) {
@@ -8491,139 +8530,139 @@ $.jgrid.extend({
8491
8530
  return [pos,rowsInGrid];
8492
8531
  }
8493
8532
 
8494
- if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
8495
- if(onBeforeInit) {
8496
- showFrm = onBeforeInit.call($t,$("#"+frmgr));
8497
- if(showFrm === undefined) {
8498
- showFrm = true;
8499
- }
8533
+ var dh = isNaN(rp_ge[$(this)[0].p.id].dataheight) ? rp_ge[$(this)[0].p.id].dataheight : rp_ge[$(this)[0].p.id].dataheight+"px",
8534
+ dw = isNaN(rp_ge[$(this)[0].p.id].datawidth) ? rp_ge[$(this)[0].p.id].datawidth : rp_ge[$(this)[0].p.id].datawidth+"px",
8535
+ frm = $("<form name='FormPost' id='"+frmgr_id+"' class='FormGrid' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>"),
8536
+ tbl =$("<table id='"+frmtb_id+"' class='EditTable' cellspacing='1' cellpadding='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
8537
+ if(onBeforeInit) {
8538
+ showFrm = onBeforeInit.call($t,$("#"+frmgr));
8539
+ if(showFrm === undefined) {
8540
+ showFrm = true;
8500
8541
  }
8501
- if(showFrm === false) {return;}
8502
- $(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
8503
- $("#FormError","#"+frmtb).hide();
8504
- fillData(rowid,$t);
8505
- if($.isFunction(rp_ge[$t.p.id].beforeShowForm)) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+frmgr));}
8506
- $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal});
8507
- focusaref();
8508
- } else {
8509
- var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px",
8510
- dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px",
8511
- frm = $("<form name='FormPost' id='"+frmgr_id+"' class='FormGrid' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>"),
8512
- tbl =$("<table id='"+frmtb_id+"' class='EditTable' cellspacing='1' cellpadding='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
8513
- if(onBeforeInit) {
8514
- showFrm = onBeforeInit.call($t,$("#"+frmgr));
8515
- if(showFrm === undefined) {
8516
- showFrm = true;
8542
+ }
8543
+ if(showFrm === false) {return;}
8544
+ $($t.p.colModel).each( function() {
8545
+ var fmto = this.formoptions;
8546
+ maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
8547
+ maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
8548
+ });
8549
+ // set the id.
8550
+ $(frm).append(tbl);
8551
+ createData(rowid, $t, tbl, maxCols);
8552
+ var rtlb = $t.p.direction === "rtl" ? true :false,
8553
+ bp = rtlb ? "nData" : "pData",
8554
+ bn = rtlb ? "pData" : "nData",
8555
+ // buttons at footer
8556
+ bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
8557
+ bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
8558
+ bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bClose+"</a>";
8559
+ if(maxRows > 0) {
8560
+ var sd=[];
8561
+ $.each($(tbl)[0].rows,function(i,r){
8562
+ sd[i] = r;
8563
+ });
8564
+ sd.sort(function(a,b){
8565
+ if(a.rp > b.rp) {return 1;}
8566
+ if(a.rp < b.rp) {return -1;}
8567
+ return 0;
8568
+ });
8569
+ $.each(sd, function(index, row) {
8570
+ $('tbody',tbl).append(row);
8571
+ });
8572
+ }
8573
+ p.gbox = "#gbox_"+$.jgrid.jqID(gID);
8574
+ var bt = $("<div></div>").append(frm).append("<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton' width='"+p.labelswidth+"'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bC+"</td></tr></tbody></table>");
8575
+ $.jgrid.createModal(IDs,bt,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
8576
+ if(rtlb) {
8577
+ $("#pData, #nData","#"+frmtb+"_2").css("float","right");
8578
+ $(".EditButton","#"+frmtb+"_2").css("text-align","left");
8579
+ }
8580
+ if(!p.viewPagerButtons) {$("#pData, #nData","#"+frmtb+"_2").hide();}
8581
+ bt = null;
8582
+ $("#"+IDs.themodal).keydown( function( e ) {
8583
+ if(e.which === 27) {
8584
+ if(rp_ge[$t.p.id].closeOnEscape) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose});}
8585
+ return false;
8586
+ }
8587
+ if(p.navkeys[0]===true) {
8588
+ if(e.which === p.navkeys[1]){ //up
8589
+ $("#pData", "#"+frmtb+"_2").trigger("click");
8590
+ return false;
8591
+ }
8592
+ if(e.which === p.navkeys[2]){ //down
8593
+ $("#nData", "#"+frmtb+"_2").trigger("click");
8594
+ return false;
8517
8595
  }
8518
8596
  }
8519
- if(showFrm === false) {return;}
8520
- $($t.p.colModel).each( function() {
8521
- var fmto = this.formoptions;
8522
- maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
8523
- maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
8524
- });
8525
- // set the id.
8526
- $(frm).append(tbl);
8527
- createData(rowid, $t, tbl, maxCols);
8528
- var rtlb = $t.p.direction === "rtl" ? true :false,
8529
- bp = rtlb ? "nData" : "pData",
8530
- bn = rtlb ? "pData" : "nData",
8531
-
8532
- // buttons at footer
8533
- bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
8534
- bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
8535
- bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bClose+"</a>";
8536
- if(maxRows > 0) {
8537
- var sd=[];
8538
- $.each($(tbl)[0].rows,function(i,r){
8539
- sd[i] = r;
8540
- });
8541
- sd.sort(function(a,b){
8542
- if(a.rp > b.rp) {return 1;}
8543
- if(a.rp < b.rp) {return -1;}
8544
- return 0;
8545
- });
8546
- $.each(sd, function(index, row) {
8547
- $('tbody',tbl).append(row);
8597
+ });
8598
+ p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
8599
+ if(p.closeicon[0]===true) {
8600
+ $("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8601
+ .append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
8602
+ }
8603
+ if($.isFunction(p.beforeShowForm)) {p.beforeShowForm.call($t,$("#"+frmgr));}
8604
+ $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{
8605
+ gbox:"#gbox_"+$.jgrid.jqID(gID),
8606
+ jqm:p.jqModal,
8607
+ overlay: p.overlay,
8608
+ modal:p.modal,
8609
+ onHide : function(h) {
8610
+ $($t).data("viewProp", {
8611
+ top:parseFloat($(h.w).css("top")),
8612
+ left : parseFloat($(h.w).css("left")),
8613
+ width : $(h.w).width(),
8614
+ height : $(h.w).height(),
8615
+ dataheight : $("#"+frmgr).height(),
8616
+ datawidth: $("#"+frmgr).width()
8548
8617
  });
8618
+ h.w.remove();
8619
+ if(h.o) {h.o.remove();}
8549
8620
  }
8550
- p.gbox = "#gbox_"+$.jgrid.jqID(gID);
8551
- var bt = $("<div></div>").append(frm).append("<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton' width='"+p.labelswidth+"'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bC+"</td></tr></tbody></table>");
8552
- $.jgrid.createModal(IDs,bt,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
8553
- if(rtlb) {
8554
- $("#pData, #nData","#"+frmtb+"_2").css("float","right");
8555
- $(".EditButton","#"+frmtb+"_2").css("text-align","left");
8556
- }
8557
- if(!p.viewPagerButtons) {$("#pData, #nData","#"+frmtb+"_2").hide();}
8558
- bt = null;
8559
- $("#"+IDs.themodal).keydown( function( e ) {
8560
- if(e.which === 27) {
8561
- if(rp_ge[$t.p.id].closeOnEscape) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose});}
8562
- return false;
8621
+ });
8622
+ $(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover(
8623
+ function(){$(this).addClass('ui-state-hover');},
8624
+ function(){$(this).removeClass('ui-state-hover');}
8625
+ );
8626
+ focusaref();
8627
+ $("#cData", "#"+frmtb+"_2").click(function(){
8628
+ $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: p.onClose});
8629
+ return false;
8630
+ });
8631
+ $("#nData", "#"+frmtb+"_2").click(function(){
8632
+ $("#FormError","#"+frmtb).hide();
8633
+ var npos = getCurrPos();
8634
+ npos[0] = parseInt(npos[0],10);
8635
+ if(npos[0] !== -1 && npos[1][npos[0]+1]) {
8636
+ if($.isFunction(p.onclickPgButtons)) {
8637
+ p.onclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]]);
8563
8638
  }
8564
- if(p.navkeys[0]===true) {
8565
- if(e.which === p.navkeys[1]){ //up
8566
- $("#pData", "#"+frmtb+"_2").trigger("click");
8567
- return false;
8568
- }
8569
- if(e.which === p.navkeys[2]){ //down
8570
- $("#nData", "#"+frmtb+"_2").trigger("click");
8571
- return false;
8572
- }
8639
+ fillData(npos[1][npos[0]+1],$t);
8640
+ $($t).jqGrid("setSelection",npos[1][npos[0]+1]);
8641
+ if($.isFunction(p.afterclickPgButtons)) {
8642
+ p.afterclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]+1]);
8573
8643
  }
8574
- });
8575
- p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
8576
- if(p.closeicon[0]===true) {
8577
- $("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
8578
- .append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
8579
- }
8580
- if($.isFunction(p.beforeShowForm)) {p.beforeShowForm.call($t,$("#"+frmgr));}
8581
- $.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,overlay: p.overlay, modal:p.modal});
8582
- $(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover(
8583
- function(){$(this).addClass('ui-state-hover');},
8584
- function(){$(this).removeClass('ui-state-hover');}
8585
- );
8644
+ updateNav(npos[0]+1,npos);
8645
+ }
8586
8646
  focusaref();
8587
- $("#cData", "#"+frmtb+"_2").click(function(){
8588
- $.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: p.onClose});
8589
- return false;
8590
- });
8591
- $("#nData", "#"+frmtb+"_2").click(function(){
8592
- $("#FormError","#"+frmtb).hide();
8593
- var npos = getCurrPos();
8594
- npos[0] = parseInt(npos[0],10);
8595
- if(npos[0] !== -1 && npos[1][npos[0]+1]) {
8596
- if($.isFunction(p.onclickPgButtons)) {
8597
- p.onclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]]);
8598
- }
8599
- fillData(npos[1][npos[0]+1],$t);
8600
- $($t).jqGrid("setSelection",npos[1][npos[0]+1]);
8601
- if($.isFunction(p.afterclickPgButtons)) {
8602
- p.afterclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]+1]);
8603
- }
8604
- updateNav(npos[0]+1,npos);
8605
- }
8606
- focusaref();
8607
- return false;
8608
- });
8609
- $("#pData", "#"+frmtb+"_2").click(function(){
8610
- $("#FormError","#"+frmtb).hide();
8611
- var ppos = getCurrPos();
8612
- if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
8613
- if($.isFunction(p.onclickPgButtons)) {
8614
- p.onclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]]);
8615
- }
8616
- fillData(ppos[1][ppos[0]-1],$t);
8617
- $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
8618
- if($.isFunction(p.afterclickPgButtons)) {
8619
- p.afterclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
8620
- }
8621
- updateNav(ppos[0]-1,ppos);
8647
+ return false;
8648
+ });
8649
+ $("#pData", "#"+frmtb+"_2").click(function(){
8650
+ $("#FormError","#"+frmtb).hide();
8651
+ var ppos = getCurrPos();
8652
+ if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
8653
+ if($.isFunction(p.onclickPgButtons)) {
8654
+ p.onclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]]);
8622
8655
  }
8623
- focusaref();
8624
- return false;
8625
- });
8626
- }
8656
+ fillData(ppos[1][ppos[0]-1],$t);
8657
+ $($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
8658
+ if($.isFunction(p.afterclickPgButtons)) {
8659
+ p.afterclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
8660
+ }
8661
+ updateNav(ppos[0]-1,ppos);
8662
+ }
8663
+ focusaref();
8664
+ return false;
8665
+ });
8627
8666
  var posInit =getCurrPos();
8628
8667
  updateNav(posInit[0],posInit);
8629
8668
  });
@@ -9067,6 +9106,7 @@ $.jgrid.extend({
9067
9106
  if (!$(this).hasClass('ui-state-disabled')) {
9068
9107
  if($.isFunction(o.beforeRefresh)) {o.beforeRefresh.call($t);}
9069
9108
  $t.p.search = false;
9109
+ $t.p.resetsearch = true;
9070
9110
  try {
9071
9111
  var gID = $t.p.id;
9072
9112
  $t.p.postData.filters ="";
@@ -9320,7 +9360,7 @@ $.jgrid.extend({
9320
9360
  if(cnt > 0) {
9321
9361
  svr.id = rowid; $t.p.savedRow.push(svr);
9322
9362
  $(ind).attr("editable","1");
9323
- $("td:eq("+focus+") input",ind).focus();
9363
+ setTimeout(function(){$("td:eq("+focus+") input",ind).focus();},0);
9324
9364
  if(o.keys===true) {
9325
9365
  $(ind).bind("keydown",function(e) {
9326
9366
  if (e.keyCode === 27) {
@@ -9607,11 +9647,11 @@ $.jgrid.extend({
9607
9647
  // End compatible
9608
9648
 
9609
9649
  return this.each(function(){
9610
- var $t= this, fr, ind, ares={}, k;
9650
+ var $t= this, fr=-1, ind, ares={}, k;
9611
9651
  if (!$t.grid ) { return; }
9612
9652
  ind = $($t).jqGrid("getInd",rowid,true);
9613
9653
  if(ind === false) {return;}
9614
- var bfcr = $.isFunction( o.beforeCancelRow ) ? o.beforeCancelRow.call($t,cancelPrm, sr) : undefined;
9654
+ var bfcr = $.isFunction( o.beforeCancelRow ) ? o.beforeCancelRow.call($t, o, sr) : undefined;
9615
9655
  if( bfcr === undefined ) {
9616
9656
  bfcr = true;
9617
9657
  }
@@ -9785,7 +9825,7 @@ $.jgrid.extend({
9785
9825
  var sr = $t.p.savedRow[0].id;
9786
9826
  if(sr) {
9787
9827
  var opers = $t.p.prmNames,
9788
- oper = opers.oper, tmpParams = {};
9828
+ oper = opers.oper, tmpParams = o.editParams;
9789
9829
  if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
9790
9830
  o.addParams.addRowParams.extraparam[oper] = opers.addoper;
9791
9831
  tmpParams = o.addParams.addRowParams;
@@ -9794,7 +9834,6 @@ $.jgrid.extend({
9794
9834
  o.editParams.extraparam = {};
9795
9835
  }
9796
9836
  o.editParams.extraparam[oper] = opers.editoper;
9797
- tmpParams = o.editParams;
9798
9837
  }
9799
9838
  if( $($t).jqGrid('saveRow', sr, tmpParams) ) {
9800
9839
  $($t).jqGrid('showAddEditButtons');
@@ -9813,12 +9852,10 @@ $.jgrid.extend({
9813
9852
  buttonicon : o.cancelicon,
9814
9853
  id : $t.p.id+"_ilcancel",
9815
9854
  onClickButton : function () {
9816
- var sr = $t.p.savedRow[0].id, cancelPrm = {};
9855
+ var sr = $t.p.savedRow[0].id, cancelPrm = o.editParams;
9817
9856
  if(sr) {
9818
9857
  if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
9819
9858
  cancelPrm = o.addParams.addRowParams;
9820
- } else {
9821
- cancelPrm = o.editParams;
9822
9859
  }
9823
9860
  $($t).jqGrid('restoreRow', sr, cancelPrm);
9824
9861
  $($t).jqGrid('showAddEditButtons');
@@ -11388,7 +11425,9 @@ $.jgrid.extend({
11388
11425
  }
11389
11426
 
11390
11427
  grp.lastvalues=[];
11391
- grp.groups =[];
11428
+ if(!grp._locgr) {
11429
+ grp.groups =[];
11430
+ }
11392
11431
  grp.counters =[];
11393
11432
  for(i=0;i<grp.groupField.length;i++) {
11394
11433
  if(!grp.groupOrder[i]) {
@@ -11403,6 +11442,9 @@ $.jgrid.extend({
11403
11442
  if( typeof grp.groupSummary[i] !== 'boolean') {
11404
11443
  grp.groupSummary[i] = false;
11405
11444
  }
11445
+ if( !grp.groupSummaryPos[i]) {
11446
+ grp.groupSummaryPos[i] = 'footer';
11447
+ }
11406
11448
  if(grp.groupColumnShow[i] === true) {
11407
11449
  grp.visibiltyOnNextGrouping[i] = true;
11408
11450
  $($t).jqGrid('showCol',grp.groupField[i]);
@@ -11412,7 +11454,15 @@ $.jgrid.extend({
11412
11454
  }
11413
11455
  }
11414
11456
  grp.summary =[];
11457
+ if(grp.hideFirstGroupCol) {
11458
+ grp.formatDisplayField[0] = function (v) { return v;};
11459
+ }
11415
11460
  for(j=0, cml = cm.length; j < cml; j++) {
11461
+ if(grp.hideFirstGroupCol) {
11462
+ if(!cm[j].hidden && grp.groupField[0] === cm[j].name) {
11463
+ cm[j].formatter = function(){return '';};
11464
+ }
11465
+ }
11416
11466
  if(cm[j].summaryType ) {
11417
11467
  if(cm[j].summaryDivider) {
11418
11468
  grp.summary.push({nm:cm[j].name,st:cm[j].summaryType, v: '', sd:cm[j].summaryDivider, vd:'', sr: cm[j].summaryRound, srt: cm[j].summaryRoundType || 'round'});
@@ -11427,7 +11477,7 @@ $.jgrid.extend({
11427
11477
  }
11428
11478
  });
11429
11479
  },
11430
- groupingPrepare : function (rData, gdata, record, irow) {
11480
+ groupingPrepare : function ( record, irow ) {
11431
11481
  this.each(function(){
11432
11482
  var grp = this.p.groupingView, $t= this, i,
11433
11483
  grlen = grp.groupField.length,
@@ -11516,9 +11566,9 @@ $.jgrid.extend({
11516
11566
  }
11517
11567
  }
11518
11568
  }
11519
- gdata.push( rData );
11569
+ //gdata.push( rData );
11520
11570
  });
11521
- return gdata;
11571
+ return this;
11522
11572
  },
11523
11573
  groupingToggle : function(hid){
11524
11574
  this.each(function(){
@@ -11543,7 +11593,10 @@ $.jgrid.extend({
11543
11593
  },
11544
11594
  itemGroupingLevel,
11545
11595
  showData,
11546
- collapsed = false;
11596
+ collapsed = false,
11597
+ frz = $t.p.frozenColumns ? $t.p.id+"_frozen" : false,
11598
+ tar2 = frz ? $("#"+$.jgrid.jqID(hid), "#"+$.jgrid.jqID(frz) ) : false,
11599
+ r2 = (tar2 && tar2.length) ? tar2[0].nextSibling : null;
11547
11600
  if( tarspan.hasClass(minus) ) {
11548
11601
  if(grp.showSummaryOnHide) {
11549
11602
  if(r){
@@ -11556,6 +11609,10 @@ $.jgrid.extend({
11556
11609
  }
11557
11610
  $(r).hide();
11558
11611
  r = r.nextSibling;
11612
+ if(frz) {
11613
+ $(r2).hide();
11614
+ r2 = r2.nextSibling;
11615
+ }
11559
11616
  }
11560
11617
  }
11561
11618
  } else {
@@ -11567,6 +11624,10 @@ $.jgrid.extend({
11567
11624
  }
11568
11625
  $(r).hide();
11569
11626
  r = r.nextSibling;
11627
+ if(frz) {
11628
+ $(r2).hide();
11629
+ r2 = r2.nextSibling;
11630
+ }
11570
11631
  }
11571
11632
  }
11572
11633
  }
@@ -11586,11 +11647,20 @@ $.jgrid.extend({
11586
11647
  }
11587
11648
  if (itemGroupingLevel === num + 1) {
11588
11649
  $(r).show().find(">td>span."+"tree-wrap-"+$t.p.direction).removeClass(minus).addClass(plus);
11650
+ if(frz) {
11651
+ $(r2).show().find(">td>span."+"tree-wrap-"+$t.p.direction).removeClass(minus).addClass(plus);
11652
+ }
11589
11653
  }
11590
11654
  } else if (showData) {
11591
11655
  $(r).show();
11656
+ if(frz) {
11657
+ $(r2).show();
11658
+ }
11592
11659
  }
11593
11660
  r = r.nextSibling;
11661
+ if(frz) {
11662
+ r2 = r2.nextSibling;
11663
+ }
11594
11664
  }
11595
11665
  }
11596
11666
  tarspan.removeClass(plus).addClass(minus);
@@ -11601,7 +11671,7 @@ $.jgrid.extend({
11601
11671
  });
11602
11672
  return false;
11603
11673
  },
11604
- groupingRender : function (grdata, colspans ) {
11674
+ groupingRender : function (grdata, colspans, page, rn ) {
11605
11675
  return this.each(function(){
11606
11676
  var $t = this,
11607
11677
  grp = $t.p.groupingView,
@@ -11636,9 +11706,49 @@ $.jgrid.extend({
11636
11706
  }
11637
11707
  return ret;
11638
11708
  }
11709
+ function buildSummaryTd(i, ik, grp, foffset) {
11710
+ var fdata = findGroupIdx(i, ik, grp),
11711
+ cm = $t.p.colModel,
11712
+ vv, grlen = fdata.cnt, str="", k;
11713
+ for(k=foffset; k<colspans;k++) {
11714
+ var tmpdata = "<td "+$t.formatCol(k,1,'')+">&#160;</td>",
11715
+ tplfld = "{0}";
11716
+ $.each(fdata.summary,function(){
11717
+ if(this.nm === cm[k].name) {
11718
+ if(cm[k].summaryTpl) {
11719
+ tplfld = cm[k].summaryTpl;
11720
+ }
11721
+ if(typeof this.st === 'string' && this.st.toLowerCase() === 'avg') {
11722
+ if(this.sd && this.vd) {
11723
+ this.v = (this.v/this.vd);
11724
+ } else if(this.v && grlen > 0) {
11725
+ this.v = (this.v/grlen);
11726
+ }
11727
+ }
11728
+ try {
11729
+ this.groupCount = fdata.cnt;
11730
+ this.groupIndex = fdata.dataIndex;
11731
+ this.groupValue = fdata.value;
11732
+ vv = $t.formatter('', this.v, k, this);
11733
+ } catch (ef) {
11734
+ vv = this.v;
11735
+ }
11736
+ tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
11737
+ return false;
11738
+ }
11739
+ });
11740
+ str += tmpdata;
11741
+ }
11742
+ return str;
11743
+ }
11639
11744
  var sumreverse = $.makeArray(grp.groupSummary);
11640
11745
  sumreverse.reverse();
11641
11746
  $.each(grp.groups,function(i,n){
11747
+ if(grp._locgr) {
11748
+ if( !(n.startRow +n.cnt > (page-1)*rn && n.startRow < page*rn)) {
11749
+ return true;
11750
+ }
11751
+ }
11642
11752
  toEnd++;
11643
11753
  clid = $t.p.id+"ghead_"+n.idx;
11644
11754
  hid = clid+"_"+i;
@@ -11653,62 +11763,49 @@ $.jgrid.extend({
11653
11763
  } catch (egv) {
11654
11764
  gv = n.displayValue;
11655
11765
  }
11656
- str += "<tr id=\""+hid+"\"" +(grp.groupCollapse && n.idx>0 ? " style=\"display:none;\" " : " ") + "role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+" "+clid+"\"><td style=\"padding-left:"+(n.idx * 12) + "px;"+"\" colspan=\""+colspans+"\">"+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+"</td></tr>";
11766
+ if(grp.groupSummaryPos[n.idx] === 'header') {
11767
+ str += "<tr id=\""+hid+"\"" +(grp.groupCollapse && n.idx>0 ? " style=\"display:none;\" " : " ") + "role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+" "+clid+"\"><td style=\"padding-left:"+(n.idx * 12) + "px;"+"\">"+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+"</td>";
11768
+ str += buildSummaryTd(i, n.idx-1, grp.groups, 1);
11769
+ str += "</tr>";
11770
+ } else {
11771
+ str += "<tr id=\""+hid+"\"" +(grp.groupCollapse && n.idx>0 ? " style=\"display:none;\" " : " ") + "role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+" "+clid+"\"><td style=\"padding-left:"+(n.idx * 12) + "px;"+"\" colspan=\""+colspans+"\">"+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+"</td></tr>";
11772
+ }
11657
11773
  var leaf = len-1 === n.idx;
11658
11774
  if( leaf ) {
11659
- var gg = grp.groups[i+1], k, kk, ik;
11660
- var end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length;
11661
- for(kk=n.startRow;kk<end;kk++) {
11662
- str += grdata[kk].join('');
11663
- }
11664
- var jj;
11665
- if (gg !== undefined) {
11666
- for (jj = 0; jj < grp.groupField.length; jj++) {
11667
- if (gg.dataIndex === grp.groupField[jj]) {
11668
- break;
11775
+ var gg = grp.groups[i+1], kk, ik, offset = 0, sgr = n.startRow,
11776
+ end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length;
11777
+ if(grp._locgr) {
11778
+ offset = (page-1)*rn;
11779
+ if(offset > n.startRow) {
11780
+ sgr = offset;
11781
+ }
11782
+ }
11783
+ for(kk=sgr;kk<end;kk++) {
11784
+ if(!grdata[kk - offset]) { break; }
11785
+ str += grdata[kk - offset].join('');
11786
+ }
11787
+ if(grp.groupSummaryPos[n.idx] !== 'header') {
11788
+ var jj;
11789
+ if (gg !== undefined) {
11790
+ for (jj = 0; jj < grp.groupField.length; jj++) {
11791
+ if (gg.dataIndex === grp.groupField[jj]) {
11792
+ break;
11793
+ }
11669
11794
  }
11795
+ toEnd = grp.groupField.length - jj;
11670
11796
  }
11671
- toEnd = grp.groupField.length - jj;
11672
- }
11673
- for (ik = 0; ik < toEnd; ik++) {
11674
- if(!sumreverse[ik]) { continue; }
11675
- var hhdr = "";
11676
- if(grp.groupCollapse && !grp.showSummaryOnHide) {
11677
- hhdr = " style=\"display:none;\"";
11678
- }
11679
- str += "<tr"+hhdr+" jqfootlevel=\""+(n.idx-ik)+"\" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
11680
- var fdata = findGroupIdx(i, ik, grp.groups),
11681
- cm = $t.p.colModel,
11682
- vv, grlen = fdata.cnt;
11683
- for(k=0; k<colspans;k++) {
11684
- var tmpdata = "<td "+$t.formatCol(k,1,'')+">&#160;</td>",
11685
- tplfld = "{0}";
11686
- $.each(fdata.summary,function(){
11687
- if(this.nm === cm[k].name) {
11688
- if(cm[k].summaryTpl) {
11689
- tplfld = cm[k].summaryTpl;
11690
- }
11691
- if(typeof this.st === 'string' && this.st.toLowerCase() === 'avg') {
11692
- if(this.sd && this.vd) {
11693
- this.v = (this.v/this.vd);
11694
- } else if(this.v && grlen > 0) {
11695
- this.v = (this.v/grlen);
11696
- }
11697
- }
11698
- try {
11699
- vv = $t.formatter('', this.v, k, this);
11700
- } catch (ef) {
11701
- vv = this.v;
11702
- }
11703
- tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
11704
- return false;
11705
- }
11706
- });
11707
- str += tmpdata;
11797
+ for (ik = 0; ik < toEnd; ik++) {
11798
+ if(!sumreverse[ik]) { continue; }
11799
+ var hhdr = "";
11800
+ if(grp.groupCollapse && !grp.showSummaryOnHide) {
11801
+ hhdr = " style=\"display:none;\"";
11802
+ }
11803
+ str += "<tr"+hhdr+" jqfootlevel=\""+(n.idx-ik)+"\" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
11804
+ str += buildSummaryTd(i, ik, grp.groups, 0);
11805
+ str += "</tr>";
11708
11806
  }
11709
- str += "</tr>";
11807
+ toEnd = jj;
11710
11808
  }
11711
- toEnd = jj;
11712
11809
  }
11713
11810
  });
11714
11811
  $("#"+$.jgrid.jqID($t.p.id)+" tbody:first").append(str);
@@ -12335,7 +12432,7 @@ $.jgrid.extend({
12335
12432
  delete opts.update;
12336
12433
  } else {opts._update_ = false;}
12337
12434
  opts.start = function(ev,ui) {
12338
- $(ui.item).css("border-width","0px");
12435
+ $(ui.item).css("border-width","0");
12339
12436
  $("td",ui.item).each(function(i){
12340
12437
  this.style.width = $t.grid.cols[i].style.width;
12341
12438
  });
@@ -12660,3 +12757,479 @@ jQuery(selector).each(function() {
12660
12757
  }
12661
12758
  });
12662
12759
  };
12760
+ /*jshint eqeqeq:false */
12761
+ /*global jQuery */
12762
+ (function($){
12763
+ /**
12764
+ * jqGrid pivot functions
12765
+ * Tony Tomov tony@trirand.com
12766
+ * http://trirand.com/blog/
12767
+ * Dual licensed under the MIT and GPL licenses:
12768
+ * http://www.opensource.org/licenses/mit-license.php
12769
+ * http://www.gnu.org/licenses/gpl-2.0.html
12770
+ */
12771
+ "use strict";
12772
+ // To optimize the search we need custom array filter
12773
+ // This code is taken from
12774
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
12775
+
12776
+ function _pivotfilter (fn, context) {
12777
+ var i,
12778
+ value,
12779
+ result = [],
12780
+ length;
12781
+
12782
+ if (!this || typeof fn !== 'function' || (fn instanceof RegExp)) {
12783
+ throw new TypeError();
12784
+ }
12785
+
12786
+ length = this.length;
12787
+
12788
+ for (i = 0; i < length; i++) {
12789
+ if (this.hasOwnProperty(i)) {
12790
+ value = this[i];
12791
+ if (fn.call(context, value, i, this)) {
12792
+ result.push(value);
12793
+ // We need break in order to cancel loop
12794
+ // in case the row is found
12795
+ break;
12796
+ }
12797
+ }
12798
+ }
12799
+ return result;
12800
+ }
12801
+ $.assocArraySize = function(obj) {
12802
+ // http://stackoverflow.com/a/6700/11236
12803
+ var size = 0, key;
12804
+ for (key in obj) {
12805
+ if (obj.hasOwnProperty(key)) {
12806
+ size++;
12807
+ }
12808
+ }
12809
+ return size;
12810
+ };
12811
+
12812
+ $.jgrid.extend({
12813
+ pivotSetup : function( data, options ){
12814
+ // data should come in json format
12815
+ // The function return the new colModel and the transformed data
12816
+ // again with group setup options which then will be passed to the grid
12817
+ var columns =[],
12818
+ pivotrows =[],
12819
+ summaries = [],
12820
+ member=[],
12821
+ groupOptions = {
12822
+ grouping : true,
12823
+ groupingView : {
12824
+ groupField : [],
12825
+ groupSummary: [],
12826
+ groupSummaryPos:[]
12827
+ }
12828
+ },
12829
+ headers = [],
12830
+ o = $.extend ( {
12831
+ rowTotals : false,
12832
+ rowTotalsText : 'Total',
12833
+ // summary columns
12834
+ colTotals : false,
12835
+ groupSummary : true,
12836
+ groupSummaryPos : 'header',
12837
+ frozenStaticCols : false
12838
+ }, options || {});
12839
+ this.each(function(){
12840
+
12841
+ var
12842
+ row,
12843
+ rowindex,
12844
+ i,
12845
+
12846
+ rowlen = data.length,
12847
+ xlen, ylen, aggrlen,
12848
+ tmp,
12849
+ newObj,
12850
+ r=0;
12851
+ // utility funcs
12852
+ /*
12853
+ * Filter the data to a given criteria. Return the firt occurance
12854
+ */
12855
+ function find(ar, fun, extra) {
12856
+ var res;
12857
+ res = _pivotfilter.call(ar, fun, extra);
12858
+ return res.length > 0 ? res[0] : null;
12859
+ }
12860
+ /*
12861
+ * Check if the grouped row column exist (See find)
12862
+ * If the row is not find in pivot rows retun null,
12863
+ * otherviese the column
12864
+ */
12865
+ function findGroup(item, index) {
12866
+ var j = 0, ret = true, i;
12867
+ for(i in item) {
12868
+ if(item[i] != this[j]) {
12869
+ ret = false;
12870
+ break;
12871
+ }
12872
+ j++;
12873
+ if(j>=this.length) {
12874
+ break;
12875
+ }
12876
+ }
12877
+ if(ret) {
12878
+ rowindex = index;
12879
+ }
12880
+ return ret;
12881
+ }
12882
+ /*
12883
+ * Perform calculations of the pivot values.
12884
+ */
12885
+ function calculation(oper, v, field, rc) {
12886
+ var ret;
12887
+ switch (oper) {
12888
+ case "sum" :
12889
+ ret = parseFloat(v||0) + parseFloat((rc[field]||0));
12890
+ break;
12891
+ case "count" :
12892
+ if(v==="" || v == null) {
12893
+ v=0;
12894
+ }
12895
+ if(rc.hasOwnProperty(field)) {
12896
+ ret = v+1;
12897
+ } else {
12898
+ ret = 0;
12899
+ }
12900
+ break;
12901
+ case "min" :
12902
+ if(v==="" || v == null) {
12903
+ ret = parseFloat(rc[field]||0);
12904
+ } else {
12905
+ ret =Math.min(parseFloat(v),parseFloat(rc[field]||0));
12906
+ }
12907
+ break;
12908
+ case "max" :
12909
+ if(v==="" || v == null) {
12910
+ ret = parseFloat(rc[field]||0);
12911
+ } else {
12912
+ ret = Math.max(parseFloat(v),parseFloat(rc[field]||0));
12913
+ }
12914
+ break;
12915
+ }
12916
+ return ret;
12917
+ }
12918
+ /*
12919
+ * The function agragates the values of the pivot grid.
12920
+ * Return the current row with pivot summary values
12921
+ */
12922
+ function agregateFunc ( row, aggr, value, curr) {
12923
+ // default is sum
12924
+ var arrln = aggr.length, i, label, j, jv;
12925
+ if($.isArray(value)) {
12926
+ jv = value.length;
12927
+ } else {
12928
+ jv = 1;
12929
+ }
12930
+ member = [];
12931
+ member.root = 0;
12932
+ for(j=0;j<jv;j++) {
12933
+ var tmpmember = [], vl;
12934
+ for(i=0; i < arrln; i++) {
12935
+ if(value == null) {
12936
+ label = $.trim(aggr[i].member)+"_"+aggr[i].aggregator;
12937
+ vl = label;
12938
+ } else {
12939
+ vl = value[j].replace(/\s+/g, '');
12940
+ try {
12941
+ label = (arrln === 1 ? vl : vl+"_"+aggr[i].aggregator+"_"+i);
12942
+ } catch(e) {}
12943
+ }
12944
+ curr[label] = tmpmember[label] = calculation( aggr[i].aggregator, curr[label], aggr[i].member, row);
12945
+ }
12946
+ member[vl] = tmpmember;
12947
+ }
12948
+ return curr;
12949
+ }
12950
+ // Making the row totals without to add in yDimension
12951
+ if(o.rowTotals && o.yDimension.length > 0) {
12952
+ var dn = o.yDimension[0].dataName;
12953
+ o.yDimension.splice(0,0,{dataName:dn});
12954
+ o.yDimension[0].converter = function(){ return '_r_Totals'; };
12955
+ }
12956
+ // build initial columns (colModel) from xDimension
12957
+ xlen = $.isArray(o.xDimension) ? o.xDimension.length : 0;
12958
+ ylen = o.yDimension.length;
12959
+ aggrlen = $.isArray(o.aggregates) ? o.aggregates.length : 0;
12960
+ if(xlen === 0 || aggrlen === 0) {
12961
+ throw("xDimension or aggregates optiona are not set!");
12962
+ }
12963
+ var colc;
12964
+ for(i = 0; i< xlen; i++) {
12965
+ colc = {name:o.xDimension[i].dataName, frozen: o.frozenStaticCols};
12966
+ colc = $.extend(true, colc, o.xDimension[i]);
12967
+ columns.push( colc );
12968
+ }
12969
+ var groupfields = xlen - 1, tree={};
12970
+ //tree = { text: 'root', leaf: false, children: [] };
12971
+ //loop over alll the source data
12972
+ while( r < rowlen ) {
12973
+ row = data[r];
12974
+ var xValue = [];
12975
+ var yValue = [];
12976
+ tmp = {};
12977
+ i = 0;
12978
+ // build the data from xDimension
12979
+ do {
12980
+ xValue[i] = $.trim(row[o.xDimension[i].dataName]);
12981
+ tmp[o.xDimension[i].dataName] = xValue[i];
12982
+ i++;
12983
+ } while( i < xlen );
12984
+
12985
+ var k = 0;
12986
+ rowindex = -1;
12987
+ // check to see if the row is in our new pivotrow set
12988
+ newObj = find(pivotrows, findGroup, xValue);
12989
+ if(!newObj) {
12990
+ // if the row is not in our set
12991
+ k = 0;
12992
+ // if yDimension is set
12993
+ if(ylen>=1) {
12994
+ // build the cols set in yDimension
12995
+ for(k=0;k<ylen;k++) {
12996
+ yValue[k] = $.trim(row[o.yDimension[k].dataName]);
12997
+ // Check to see if we have user defined conditions
12998
+ if(o.yDimension[k].converter && $.isFunction(o.yDimension[k].converter)) {
12999
+ yValue[k] = o.yDimension[k].converter.call(this, yValue[k], xValue, yValue);
13000
+ }
13001
+ }
13002
+ // make the colums based on aggregates definition
13003
+ // and return the members for late calculation
13004
+ tmp = agregateFunc( row, o.aggregates, yValue, tmp );
13005
+ } else if( ylen === 0 ) {
13006
+ // if not set use direct the aggregates
13007
+ tmp = agregateFunc( row, o.aggregates, null, tmp );
13008
+ }
13009
+ // add the result in pivot rows
13010
+ pivotrows.push( tmp );
13011
+ } else {
13012
+ // the pivot exists
13013
+ if( rowindex >= 0) {
13014
+ k = 0;
13015
+ // make the recalculations
13016
+ if(ylen>=1) {
13017
+ for(k=0;k<ylen;k++) {
13018
+ yValue[k] = $.trim(row[o.yDimension[k].dataName]);
13019
+ if(o.yDimension[k].converter && $.isFunction(o.yDimension[k].converter)) {
13020
+ yValue[k] = o.yDimension[k].converter.call(this, yValue[k], xValue, yValue);
13021
+ }
13022
+ }
13023
+ newObj = agregateFunc( row, o.aggregates, yValue, newObj );
13024
+ } else if( ylen === 0 ) {
13025
+ newObj = agregateFunc( row, o.aggregates, null, newObj );
13026
+ }
13027
+ // update the row
13028
+ pivotrows[rowindex] = newObj;
13029
+ }
13030
+ }
13031
+ var kj=0, current = null,existing = null, kk;
13032
+ // Build a JSON tree from the member (see aggregateFunc)
13033
+ // to make later the columns
13034
+ //
13035
+ for (kk in member) {
13036
+ if(kj === 0) {
13037
+ if (!tree.children||tree.children === undefined){
13038
+ tree = { text: kk, level : 0, children: [] };
13039
+ }
13040
+ current = tree.children;
13041
+ } else {
13042
+ existing = null;
13043
+ for (i=0; i < current.length; i++) {
13044
+ if (current[i].text === kk) {
13045
+ //current[i].fields=member[kk];
13046
+ existing = current[i];
13047
+ break;
13048
+ }
13049
+ }
13050
+ if (existing) {
13051
+ current = existing.children;
13052
+ } else {
13053
+ current.push({ children: [], text: kk, level: kj, fields: member[kk] });
13054
+ current = current[current.length - 1].children;
13055
+ }
13056
+ }
13057
+ kj++;
13058
+ }
13059
+ r++;
13060
+ }
13061
+ var lastval=[], initColLen = columns.length, swaplen = initColLen;
13062
+ if(ylen>0) {
13063
+ headers[ylen-1] = { useColSpanStyle: false, groupHeaders: []};
13064
+ }
13065
+ /*
13066
+ * Recursive function which uses the tree to build the
13067
+ * columns from the pivot values and set the group Headers
13068
+ */
13069
+ function list(items) {
13070
+ var l, j, key, k, col;
13071
+ for (key in items) { // iterate
13072
+ if (items.hasOwnProperty(key)) {
13073
+ // write amount of spaces according to level
13074
+ // and write name and newline
13075
+ if(typeof items[key] !== "object") {
13076
+ // If not a object build the header of the appropriate level
13077
+ if( key === 'level') {
13078
+ if(lastval[items.level] === undefined) {
13079
+ lastval[items.level] ='';
13080
+ if(items.level>0 && items.text !== '_r_Totals') {
13081
+ headers[items.level-1] = {
13082
+ useColSpanStyle: false,
13083
+ groupHeaders: []
13084
+ };
13085
+ }
13086
+ }
13087
+ if(lastval[items.level] !== items.text && items.children.length && items.text !== '_r_Totals') {
13088
+ if(items.level>0) {
13089
+ headers[items.level-1].groupHeaders.push({
13090
+ titleText: items.text
13091
+ });
13092
+ var collen = headers[items.level-1].groupHeaders.length,
13093
+ colpos = collen === 1 ? swaplen : initColLen+(collen-1)*aggrlen;
13094
+ headers[items.level-1].groupHeaders[collen-1].startColumnName = columns[colpos].name;
13095
+ headers[items.level-1].groupHeaders[collen-1].numberOfColumns = columns.length - colpos;
13096
+ initColLen = columns.length;
13097
+ }
13098
+ }
13099
+ lastval[items.level] = items.text;
13100
+ }
13101
+ // This is in case when the member contain more than one summary item
13102
+ if(items.level === ylen && key==='level' && ylen >0) {
13103
+ if( aggrlen > 1){
13104
+ var ll=1;
13105
+ for( l in items.fields) {
13106
+ if(ll===1) {
13107
+ headers[ylen-1].groupHeaders.push({startColumnName: l, numberOfColumns: 1, titleText: items.text});
13108
+ }
13109
+ ll++;
13110
+ }
13111
+ headers[ylen-1].groupHeaders[headers[ylen-1].groupHeaders.length-1].numberOfColumns = ll-1;
13112
+ } else {
13113
+ headers.splice(ylen-1,1);
13114
+ }
13115
+ }
13116
+ }
13117
+ // if object, call recursively
13118
+ if (items[key] != null && typeof items[key] === "object") {
13119
+ list(items[key]);
13120
+ }
13121
+ // Finally build the coulumns
13122
+ if( key === 'level') {
13123
+ if(items.level >0){
13124
+ j=0;
13125
+ for(l in items.fields) {
13126
+ col = {};
13127
+ for(k in o.aggregates[j]) {
13128
+ if(o.aggregates[j].hasOwnProperty(k)) {
13129
+ switch( k ) {
13130
+ case 'member':
13131
+ case 'label':
13132
+ case 'aggregator':
13133
+ break;
13134
+ default:
13135
+ col[k] = o.aggregates[j][k];
13136
+ }
13137
+ }
13138
+ }
13139
+ if(aggrlen>1) {
13140
+ col.name = l;
13141
+ col.label = o.aggregates[j].label || l;
13142
+ } else {
13143
+ col.name = items.text;
13144
+ col.label = items.text==='_r_Totals' ? o.rowTotalsText : items.text;
13145
+ }
13146
+ columns.push (col);
13147
+ j++;
13148
+ }
13149
+ }
13150
+ }
13151
+ }
13152
+ }
13153
+ }
13154
+
13155
+ list(tree, 0);
13156
+ var nm;
13157
+ // loop again trougth the pivot rows in order to build grand total
13158
+ if(o.colTotals) {
13159
+ var plen = pivotrows.length;
13160
+ while(plen--) {
13161
+ for(i=xlen;i<columns.length;i++) {
13162
+ nm = columns[i].name;
13163
+ if(!summaries[nm]) {
13164
+ summaries[nm] = parseFloat(pivotrows[plen][nm] || 0);
13165
+ } else {
13166
+ summaries[nm] += parseFloat(pivotrows[plen][nm] || 0);
13167
+ }
13168
+ }
13169
+ }
13170
+ }
13171
+ // based on xDimension levels build grouping
13172
+ if( groupfields > 0) {
13173
+ for(i=0;i<groupfields;i++) {
13174
+ groupOptions.groupingView.groupField[i] = columns[i].name;
13175
+ groupOptions.groupingView.groupSummary[i] = o.groupSummary;
13176
+ groupOptions.groupingView.groupSummaryPos[i] = o.groupSummaryPos;
13177
+ }
13178
+ } else {
13179
+ // no grouping is needed
13180
+ groupOptions.grouping = false;
13181
+ }
13182
+ groupOptions.sortname = columns[groupfields].name;
13183
+ groupOptions.groupingView.hideFirstGroupCol = true;
13184
+ });
13185
+ // return the final result.
13186
+ return { "colModel" : columns, "rows": pivotrows, "groupOptions" : groupOptions, "groupHeaders" : headers, summary : summaries };
13187
+ },
13188
+ jqPivot : function( data, pivotOpt, gridOpt, ajaxOpt) {
13189
+ return this.each(function(){
13190
+ var $t = this;
13191
+
13192
+ function pivot( data) {
13193
+ var pivotGrid = jQuery($t).jqGrid('pivotSetup',data, pivotOpt),
13194
+ footerrow = $.assocArraySize(pivotGrid.summary) > 0 ? true : false,
13195
+ query= $.jgrid.from(pivotGrid.rows), i;
13196
+ for(i=0; i< pivotGrid.groupOptions.groupingView.groupField.length; i++) {
13197
+ query.orderBy(pivotGrid.groupOptions.groupingView.groupField[i], "a", 'text', '');
13198
+ }
13199
+ jQuery($t).jqGrid($.extend({
13200
+ datastr: $.extend(query.select(),footerrow ? {userdata:pivotGrid.summary} : {}),
13201
+ datatype: "jsonstring",
13202
+ footerrow : footerrow,
13203
+ userDataOnFooter: footerrow,
13204
+ colModel: pivotGrid.colModel,
13205
+ viewrecords: true,
13206
+ sortname: pivotOpt.xDimension[0].dataName // ?????
13207
+ }, gridOpt || {}, pivotGrid.groupOptions));
13208
+ var gHead = pivotGrid.groupHeaders;
13209
+ if(gHead.length) {
13210
+ for( i = 0;i < gHead.length ; i++) {
13211
+ if(gHead[i] && gHead[i].groupHeaders.length) {
13212
+ jQuery($t).jqGrid('setGroupHeaders',gHead[i]);
13213
+ }
13214
+ }
13215
+ }
13216
+ if(pivotOpt.frozenStaticCols) {
13217
+ jQuery($t).jqGrid("setFrozenColumns");
13218
+ }
13219
+ }
13220
+
13221
+ if(typeof data === "string") {
13222
+ $.ajax($.extend({
13223
+ url : data,
13224
+ dataType: 'json',
13225
+ success : function(response) {
13226
+ pivot($.jgrid.getAccessor(response, ajaxOpt && ajaxOpt.reader ? ajaxOpt.reader: 'rows') );
13227
+ }
13228
+ }, ajaxOpt || {}) );
13229
+ } else {
13230
+ pivot( data );
13231
+ }
13232
+ });
13233
+ }
13234
+ });
13235
+ })(jQuery);