jqgrid-jquery-rails 4.3.3.0 → 4.4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea37827d1dc79b8fd7ebf4f5c408c9d8a967b819
4
- data.tar.gz: 765dd6d130fc64adaf9298b8c421213d738e5edd
3
+ metadata.gz: cbea0a15abf4432a9712fdda8e1f38913679b1bf
4
+ data.tar.gz: a8dbb4af2709c7898a7675d7484ed59850c9585f
5
5
  SHA512:
6
- metadata.gz: 1718ce814d061cdcca2f34c2ffb46b3484bc4df73c62ddf67f37e66e61e4c66d9a6608aaa9f487d3b5c2efcd991199c688a98ca005bfb1b15e064c4bcfa256da
7
- data.tar.gz: 806e446d6ab33db39770ed05362e985f9176ea31b3be6f997f6451d649ca99d6591266d9383b095c4b548d1a7e5ad0caf14f52ad9a462cd352263c90919db9b0
6
+ metadata.gz: 13ff7ec8f79ae79325ad93ae91fe85af25c52d49cb1445a3b40d01d81a5925ab2c0dcd8fe325130c9ec863fd7121a78461e2c848959e252a404fcf868553d7b7
7
+ data.tar.gz: 7135b4f4f99b0816c011ef17112eec9d9db96bd7d7d00e4fa3d33f18d106c9e1955a6effdf29654a32e6b08a1f18d14375b2adea91ddfa493cf92881426d3dbd
data/README.md CHANGED
@@ -10,7 +10,7 @@ Add these lines to your application's `Gemfile`:
10
10
 
11
11
  ```rb
12
12
  # jqgrid jquery plugin packaged for the rails asset pipeline
13
- gem 'jqgrid-jquery-rails', '~> 4.3.3'
13
+ gem 'jqgrid-jquery-rails', '~> 4.4.0'
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -7,6 +7,6 @@ module JqgridJquery
7
7
  # "2.0.0.pre"
8
8
  # "2.0.0.beta"
9
9
  # Refer to Semantic Versioning 2.0.0 (http://semver.org).
10
- VERSION = "4.3.3.0"
10
+ VERSION = "4.4.0.0"
11
11
  end
12
12
  end
@@ -2,12 +2,12 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license jqGrid 4.3.3 - jQuery Grid
5
+ * @license jqGrid 4.4.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: 2012-05-31
10
+ * Date: 2012-06-14
11
11
  */
12
12
  //jsHint options
13
13
  /*global document, window, jQuery, DOMParser, ActiveXObject, $, alert */
@@ -16,7 +16,7 @@
16
16
  "use strict";
17
17
  $.jgrid = $.jgrid || {};
18
18
  $.extend($.jgrid,{
19
- version : "4.3.3",
19
+ version : "4.4.0",
20
20
  htmlDecode : function(value){
21
21
  if(value && (value==' ' || value==' ' || (value.length===1 && value.charCodeAt(0)===160))) { return "";}
22
22
  return !value ? value : String(value).replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"').replace(/&amp;/g, "&");
@@ -750,7 +750,7 @@ $.fn.jqGrid = function( pin ) {
750
750
  data : [],
751
751
  _index : {},
752
752
  grouping : false,
753
- groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], groupDataSorted : false, summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus'},
753
+ groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus'},
754
754
  ignoreCase : false,
755
755
  cmTemplate : {},
756
756
  idPrefix : ""
@@ -874,7 +874,7 @@ $.fn.jqGrid = function( pin ) {
874
874
  p.page = page;
875
875
  if (empty) {
876
876
  grid.selectionPreserver(table[0]);
877
- grid.emptyRows(grid.bDiv,false, false);
877
+ grid.emptyRows.call(table[0], false, false);
878
878
  }
879
879
  grid.populate(npage);
880
880
  }
@@ -924,6 +924,12 @@ $.fn.jqGrid = function( pin ) {
924
924
  alert("Element is not a table");
925
925
  return;
926
926
  }
927
+ if(document.documentMode !== undefined ) { // IE only
928
+ if(document.documentMode <= 5) {
929
+ alert("Grid can not be used in this ('quirks') mode!");
930
+ return;
931
+ }
932
+ }
927
933
  $(this).empty().attr("tabindex","1");
928
934
  this.p = p ;
929
935
  this.p.useProp = !!$.fn.prop;
@@ -1049,20 +1055,23 @@ $.fn.jqGrid = function( pin ) {
1049
1055
  }
1050
1056
  return order;
1051
1057
  },
1052
- emptyRows = function (parent, scroll, locdata) {
1053
- if(ts.p.deepempty) {$("#"+$.jgrid.jqID(ts.p.id)+" tbody:first tr:gt(0)").remove();}
1054
- else {
1055
- var trf = $("#"+$.jgrid.jqID(ts.p.id)+" tbody:first tr:first")[0];
1056
- $("#"+$.jgrid.jqID(ts.p.id)+" tbody:first").empty().append(trf);
1057
- }
1058
- if (scroll && ts.p.scroll) {
1059
- $(">div:first", parent).css({height:"auto"}).children("div:first").css({height:0,display:"none"});
1060
- parent.scrollTop = 0;
1058
+ emptyRows = function (scroll, locdata) {
1059
+ var firstrow;
1060
+ if (this.p.deepempty) {
1061
+ $(this.rows).slice(1).remove();
1062
+ } else {
1063
+ firstrow = this.rows.length > 0 ? this.rows[0] : null;
1064
+ $(this.firstChild).empty().append(firstrow);
1061
1065
  }
1062
- if(locdata === true) {
1063
- if(ts.p.treeGrid === true ) {
1064
- ts.p.data = []; ts.p._index = {};
1066
+ if (scroll && this.p.scroll) {
1067
+ $(this.grid.bDiv.firstChild).css({height: "auto"});
1068
+ $(this.grid.bDiv.firstChild.firstChild).css({height: 0, display: "none"});
1069
+ if (this.grid.bDiv.scrollTop !== 0) {
1070
+ this.grid.bDiv.scrollTop = 0;
1071
+ }
1065
1072
  }
1073
+ if(locdata === true && this.p.treeGrid) {
1074
+ this.p.data = []; this.p._index = {};
1066
1075
  }
1067
1076
  },
1068
1077
  refreshIndex = function() {
@@ -1126,7 +1135,7 @@ $.fn.jqGrid = function( pin ) {
1126
1135
  ts.p.reccount = 0;
1127
1136
  if($.isXMLDoc(xml)) {
1128
1137
  if(ts.p.treeANode===-1 && !ts.p.scroll) {
1129
- emptyRows(t,false, true);
1138
+ emptyRows.call(ts, false, true);
1130
1139
  rcnt=1;
1131
1140
  } else { rcnt = rcnt > 1 ? rcnt :1; }
1132
1141
  } else { return; }
@@ -1166,7 +1175,7 @@ $.fn.jqGrid = function( pin ) {
1166
1175
  var gxml = $.jgrid.getXmlData( xml, xmlRd.root, true);
1167
1176
  gxml = $.jgrid.getXmlData( gxml, xmlRd.row, true);
1168
1177
  if (!gxml) { gxml = []; }
1169
- var gl = gxml.length, j=0, grpdata={}, rn = parseInt(ts.p.rowNum,10);
1178
+ var gl = gxml.length, j=0, grpdata=[], rn = parseInt(ts.p.rowNum,10);
1170
1179
  if (gl > 0 && ts.p.page <= 0) { ts.p.page = 1; }
1171
1180
  if(gxml && gl){
1172
1181
  var br=ts.p.scroll?$.jgrid.randId():1,altr;
@@ -1290,7 +1299,7 @@ $.fn.jqGrid = function( pin ) {
1290
1299
  var startReq = new Date();
1291
1300
  if(data) {
1292
1301
  if(ts.p.treeANode === -1 && !ts.p.scroll) {
1293
- emptyRows(t,false, true);
1302
+ emptyRows.call(ts, false, true);
1294
1303
  rcnt=1;
1295
1304
  } else { rcnt = rcnt > 1 ? rcnt :1; }
1296
1305
  } else { return; }
@@ -1332,7 +1341,7 @@ $.fn.jqGrid = function( pin ) {
1332
1341
  if (len > 0 && ts.p.page <= 0) { ts.p.page = 1; }
1333
1342
  var rn = parseInt(ts.p.rowNum,10),br=ts.p.scroll?$.jgrid.randId():1, altr;
1334
1343
  if (adjust) { rn *= adjust+1; }
1335
- var afterInsRow = $.isFunction(ts.p.afterInsertRow), grpdata={}, hiderow=ts.p.grouping && ts.p.groupingView.groupCollapse === true;
1344
+ var afterInsRow = $.isFunction(ts.p.afterInsertRow), grpdata=[], hiderow=ts.p.grouping && ts.p.groupingView.groupCollapse === true;
1336
1345
  while (i<len) {
1337
1346
  cur = drows[i];
1338
1347
  idr = $.jgrid.getAccessor(cur,idn);
@@ -1490,8 +1499,8 @@ $.fn.jqGrid = function( pin ) {
1490
1499
  if (typeof this.index != 'undefined') {
1491
1500
  grindex = this.index;
1492
1501
  }
1493
- grtypes[gin] = cmtypes[this.name];
1494
- grindexes[gin] = grindex;
1502
+ grtypes[gin] = cmtypes[grindex];
1503
+ grindexes[gin]= grindex;
1495
1504
  }
1496
1505
  }
1497
1506
  }
@@ -1589,7 +1598,6 @@ $.fn.jqGrid = function( pin ) {
1589
1598
  for(gin=0; gin<lengrp;gin++) {
1590
1599
  query.orderBy(grindexes[gin],grpview.groupOrder[gin],grtypes[gin].stype, grtypes[gin].srcfmt);
1591
1600
  }
1592
- grpview.groupDataSorted = true;
1593
1601
  }
1594
1602
  if (st && ts.p.sortorder && fndsort) {
1595
1603
  if(ts.p.sortorder.toUpperCase() == "DESC") {
@@ -1751,9 +1759,11 @@ $.fn.jqGrid = function( pin ) {
1751
1759
  }
1752
1760
  if(ts.p.grouping) {
1753
1761
  $(ts).jqGrid('groupingSetup');
1754
- if(ts.p.groupingView.groupDataSorted === true) {
1755
- prm[pN.sort] = ts.p.groupingView.groupField[0] +" "+ ts.p.groupingView.groupOrder[0]+", "+prm[pN.sort];
1762
+ var grp = ts.p.groupingView, gi, gs="";
1763
+ for(gi=0;gi<grp.groupField.length;gi++) {
1764
+ gs += grp.groupField[gi]+" "+grp.groupOrder[gi]+", ";
1756
1765
  }
1766
+ prm[pN.sort] = gs + prm[pN.sort];
1757
1767
  }
1758
1768
  $.extend(ts.p.postData,prm);
1759
1769
  var rcnt = !ts.p.scroll ? 1 : ts.rows.length-1;
@@ -2017,7 +2027,7 @@ $.fn.jqGrid = function( pin ) {
2017
2027
  }
2018
2028
  if(ts.p.scroll) {
2019
2029
  var sscroll = ts.grid.bDiv.scrollLeft;
2020
- emptyRows(ts.grid.bDiv,true, false);
2030
+ emptyRows.call(ts, true, false);
2021
2031
  ts.grid.hDiv.scrollLeft = sscroll;
2022
2032
  }
2023
2033
  if(ts.p.subGrid && ts.p.datatype=='local') {
@@ -2045,8 +2055,10 @@ $.fn.jqGrid = function( pin ) {
2045
2055
  cl++;
2046
2056
  }
2047
2057
  });
2048
- if(isNaN(ts.p.width)) {ts.p.width = grid.width = initwidth;}
2049
- else { grid.width = ts.p.width;}
2058
+ if(isNaN(ts.p.width)) {
2059
+ ts.p.width = initwidth + ((ts.p.shrinkToFit ===false && !isNaN(ts.p.height)) ? scw : 0);
2060
+ }
2061
+ grid.width = ts.p.width;
2050
2062
  ts.p.tblwidth = initwidth;
2051
2063
  if(ts.p.shrinkToFit ===false && ts.p.forceFit === true) {ts.p.forceFit=false;}
2052
2064
  if(ts.p.shrinkToFit===true && vc > 0) {
@@ -2436,7 +2448,7 @@ $.fn.jqGrid = function( pin ) {
2436
2448
  if(ts.p.multiselect) {ts.p.selarrrow =[];setHeadCheckBox(false);}
2437
2449
  ts.p.savedRow = [];
2438
2450
  }
2439
- if(ts.p.scroll) {emptyRows(ts.grid.bDiv,true, false);}
2451
+ if(ts.p.scroll) {emptyRows.call(ts, true, false);}
2440
2452
  if (opts && opts.page) {
2441
2453
  var page = opts.page;
2442
2454
  if (page > ts.p.lastpage) { page = ts.p.lastpage; }
@@ -2454,6 +2466,7 @@ $.fn.jqGrid = function( pin ) {
2454
2466
  } else {
2455
2467
  ts.grid.populate();
2456
2468
  }
2469
+ if(ts.p._inlinenav===true) {$(ts).jqGrid('showAddEditButtons');}
2457
2470
  return false;
2458
2471
  })
2459
2472
  .dblclick(function(e) {
@@ -2925,8 +2938,8 @@ $.jgrid.extend({
2925
2938
  for(i = gi+si+ni; i < t.p.colModel.length;i++){
2926
2939
  cm = t.p.colModel[i];
2927
2940
  nm = cm.name;
2928
- lcdata[nm] = cm.formatter && typeof(cm.formatter) === 'string' && cm.formatter == 'date' ? $.unformat.date.call(t,data[nm],cm) : data[nm];
2929
- v = t.formatter( rowid, $.jgrid.getAccessor(data,nm), i, data, 'edit');
2941
+ lcdata[nm] = data[nm];
2942
+ v = t.formatter( rowid, $.jgrid.getAccessor(data,nm), i, data );
2930
2943
  prp = t.formatCol(i,1,v, data, rowid, true);
2931
2944
  row[row.length] = "<td role=\"gridcell\" "+prp+">"+v+"</td>";
2932
2945
  }
@@ -3045,14 +3058,19 @@ $.jgrid.extend({
3045
3058
  }
3046
3059
  });
3047
3060
  if($t.p.footerrow) { $("tr.footrow td:eq("+i+")", $t.grid.sDiv).css("display", show); }
3048
- cw = this.widthOrg? this.widthOrg: parseInt(this.width,10);
3049
- if(show === "none") {$t.p.tblwidth -= cw+brd;} else {$t.p.tblwidth += cw+brd;}
3061
+ cw = parseInt(this.width,10);
3062
+ if(show === "none") {
3063
+ $t.p.tblwidth -= cw+brd;
3064
+ } else {
3065
+ $t.p.tblwidth += cw+brd;
3066
+ }
3050
3067
  this.hidden = !sw;
3051
3068
  fndh=true;
3052
3069
  $($t).triggerHandler("jqGridShowHideCol", [sw,this.name,i]);
3053
3070
  }
3054
3071
  });
3055
3072
  if(fndh===true) {
3073
+ if($t.p.shrinkToFit === true && !isNaN($t.p.height)) { $t.p.tblwidth += parseInt($t.p.scrollOffset,10);}
3056
3074
  $($t).jqGrid("setGridWidth",$t.p.shrinkToFit === true ? $t.p.tblwidth : $t.p.width );
3057
3075
  }
3058
3076
  if( gh ) {
@@ -3123,7 +3141,8 @@ $.jgrid.extend({
3123
3141
  shrink=$t.p.shrinkToFit;
3124
3142
  }
3125
3143
  if(isNaN(nwidth)) {return;}
3126
- else { nwidth = parseInt(nwidth,10); $t.grid.width = $t.p.width = nwidth;}
3144
+ nwidth = parseInt(nwidth,10);
3145
+ $t.grid.width = $t.p.width = nwidth;
3127
3146
  $("#gbox_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px");
3128
3147
  $("#gview_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px");
3129
3148
  $($t.grid.bDiv).css("width",nwidth+"px");
@@ -3139,7 +3158,7 @@ $.jgrid.extend({
3139
3158
  if(shrink===true) {
3140
3159
  $.each($t.p.colModel, function() {
3141
3160
  if(this.hidden===false){
3142
- cw = this.widthOrg? this.widthOrg: parseInt(this.width,10);
3161
+ cw = this.widthOrg;
3143
3162
  initwidth += cw+brd;
3144
3163
  if(this.fixed) {
3145
3164
  gw += cw+brd;
@@ -3162,7 +3181,7 @@ $.jgrid.extend({
3162
3181
  var cle = $t.grid.cols.length >0;
3163
3182
  $.each($t.p.colModel, function(i) {
3164
3183
  if(this.hidden === false && !this.fixed){
3165
- cw = this.widthOrg? this.widthOrg: parseInt(this.width,10);
3184
+ cw = this.widthOrg;
3166
3185
  cw = Math.round(aw*cw/($t.p.tblwidth-brd*vc-gw));
3167
3186
  if (cw < 0) { return; }
3168
3187
  this.width =cw;
@@ -4649,7 +4668,7 @@ $.extend($.jgrid,{
4649
4668
  } else {
4650
4669
  dft = g.p.colModel[valref].datefmt || "Y-m-d";
4651
4670
  }
4652
- if(!$jgrid.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; }
4671
+ if(!$.jgrid.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; }
4653
4672
  }
4654
4673
  }
4655
4674
  if(edtrul.time === true) {
@@ -8272,6 +8291,28 @@ $.jgrid.extend({
8272
8291
  // Grouping module
8273
8292
  ;(function($){
8274
8293
  "use strict";
8294
+ $.extend($.jgrid,{
8295
+ template : function(format){ //jqgformat
8296
+ var args = $.makeArray(arguments).slice(1), j = 0;
8297
+ if(format===undefined) { format = ""; }
8298
+ return format.replace(/\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g, function(m,i){
8299
+ if(!isNaN(parseInt(i,10))) {
8300
+ j++;
8301
+ return args[parseInt(i,10)];
8302
+ } else {
8303
+ var nmarr = args[ j ],
8304
+ k = nmarr.length;
8305
+ while(k--) {
8306
+ if(i===nmarr[k].nm) {
8307
+ return nmarr[k].v;
8308
+ break;
8309
+ }
8310
+ }
8311
+ j++;
8312
+ }
8313
+ });
8314
+ }
8315
+ });
8275
8316
  $.jgrid.extend({
8276
8317
  groupingSetup : function () {
8277
8318
  return this.each(function (){
@@ -8281,9 +8322,13 @@ $.jgrid.extend({
8281
8322
  if(!grp.groupField.length) {
8282
8323
  $t.p.grouping = false;
8283
8324
  } else {
8284
- if ( typeof(grp.visibiltyOnNextGrouping) == 'undefined') {
8325
+ if ( typeof(grp.visibiltyOnNextGrouping) === 'undefined') {
8285
8326
  grp.visibiltyOnNextGrouping = [];
8286
8327
  }
8328
+
8329
+ grp.lastvalues=[];
8330
+ grp.groups =[];
8331
+ grp.counters =[];
8287
8332
  for(var i=0;i<grp.groupField.length;i++) {
8288
8333
  if(!grp.groupOrder[i]) {
8289
8334
  grp.groupOrder[i] = 'asc';
@@ -8291,10 +8336,10 @@ $.jgrid.extend({
8291
8336
  if(!grp.groupText[i]) {
8292
8337
  grp.groupText[i] = '{0}';
8293
8338
  }
8294
- if( typeof(grp.groupColumnShow[i]) != 'boolean') {
8339
+ if( typeof(grp.groupColumnShow[i]) !== 'boolean') {
8295
8340
  grp.groupColumnShow[i] = true;
8296
8341
  }
8297
- if( typeof(grp.groupSummary[i]) != 'boolean') {
8342
+ if( typeof(grp.groupSummary[i]) !== 'boolean') {
8298
8343
  grp.groupSummary[i] = false;
8299
8344
  }
8300
8345
  if(grp.groupColumnShow[i] === true) {
@@ -8304,17 +8349,12 @@ $.jgrid.extend({
8304
8349
  grp.visibiltyOnNextGrouping[i] = $("#"+$.jgrid.jqID($t.p.id+"_"+grp.groupField[i])).is(":visible");
8305
8350
  $($t).jqGrid('hideCol',grp.groupField[i]);
8306
8351
  }
8307
- grp.sortitems[i] = [];
8308
- grp.sortnames[i] = [];
8309
- grp.summaryval[i] = [];
8310
- if(grp.groupSummary[i]) {
8311
- grp.summary[i] =[];
8312
- var cm = $t.p.colModel;
8313
- for(var j=0, cml = cm.length; j < cml; j++) {
8314
- if(cm[j].summaryType) {
8315
- grp.summary[i].push({nm:cm[j].name,st:cm[j].summaryType, v:''});
8316
- }
8317
- }
8352
+ }
8353
+ grp.summary =[];
8354
+ var cm = $t.p.colModel;
8355
+ for(var j=0, cml = cm.length; j < cml; j++) {
8356
+ if(cm[j].summaryType) {
8357
+ grp.summary.push({nm:cm[j].name,st:cm[j].summaryType, v: '', sr: cm[j].summaryRound, srt: cm[j].summaryRoundType || 'round'});
8318
8358
  }
8319
8359
  }
8320
8360
  }
@@ -8323,36 +8363,84 @@ $.jgrid.extend({
8323
8363
  }
8324
8364
  });
8325
8365
  },
8326
- groupingPrepare : function (rData, gdata, record) {
8366
+ groupingPrepare : function (rData, gdata, record, irow) {
8327
8367
  this.each(function(){
8328
- // currently only one level
8329
- // Is this a good idea to do it so!!!!?????
8330
8368
  var grp = this.p.groupingView, $t= this;
8331
- var grlen = grp.groupField.length, items = [];
8332
- for(var z=0;z<grlen;z++) {
8333
- items.push(record[grp.groupField[z]]);
8334
- }
8335
- items[0] += "";
8336
- var itm = items[0].toString().split(' ').join('');
8337
-
8338
- if(gdata.hasOwnProperty(itm)) {
8339
- gdata[itm].push(rData);
8340
- } else {
8341
- gdata[itm] = [];
8342
- gdata[itm].push(rData);
8343
- grp.sortitems[0].push(itm);
8344
- grp.sortnames[0].push($.trim(items[0].toString()));
8345
- grp.summaryval[0][itm] = $.extend(true,[],grp.summary[0]);
8346
- }
8347
- if(grp.groupSummary[0]) {
8348
- $.each(grp.summaryval[0][itm],function() {
8349
- if ($.isFunction(this.st)) {
8350
- this.v = this.st.call($t, this.v, this.nm, record);
8369
+ var grlen = grp.groupField.length,
8370
+ fieldName,
8371
+ v,
8372
+ changed = 0;
8373
+ for(var i=0;i<grlen;i++) {
8374
+ fieldName = grp.groupField[i];
8375
+ v = record[fieldName];
8376
+ if( v !== undefined ) {
8377
+ if(irow === 0 ) {
8378
+ // First record always starts a new group
8379
+ grp.groups.push({idx:i,dataIndex:fieldName,value:v, startRow: irow, cnt:1, summary : [] } );
8380
+ grp.lastvalues[i] = v;
8381
+ grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
8382
+ if(grp.groupSummary[i]) {
8383
+ $.each(grp.counters[i].summary,function() {
8384
+ if ($.isFunction(this.st)) {
8385
+ this.v = this.st.call($t, this.v, this.nm, record);
8386
+ } else {
8387
+ this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
8388
+ }
8389
+ });
8390
+ }
8391
+ grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
8351
8392
  } else {
8352
- this.v = $($t).jqGrid('groupingCalculations.'+this.st, this.v, this.nm, record);
8393
+ if( (typeof(v) !== "object" && (grp.lastvalues[i] !== v) ) ) {
8394
+ // This record is not in same group as previous one
8395
+ grp.groups.push({idx:i,dataIndex:fieldName,value:v, startRow: irow, cnt:1, summary : [] } );
8396
+ grp.lastvalues[i] = v;
8397
+ changed = 1;
8398
+ grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
8399
+ if(grp.groupSummary[i]) {
8400
+ $.each(grp.counters[i].summary,function() {
8401
+ if ($.isFunction(this.st)) {
8402
+ this.v = this.st.call($t, this.v, this.nm, record);
8403
+ } else {
8404
+ this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
8405
+ }
8406
+ });
8407
+ }
8408
+ grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
8409
+ } else {
8410
+ if (changed === 1) {
8411
+ // This group has changed because an earlier group changed.
8412
+ grp.groups.push({idx:i,dataIndex:fieldName,value:v, startRow: irow, cnt:1, summary : [] } );
8413
+ grp.lastvalues[i] = v;
8414
+ grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
8415
+ if(grp.groupSummary[i]) {
8416
+ $.each(grp.counters[i].summary,function() {
8417
+ if ($.isFunction(this.st)) {
8418
+ this.v = this.st.call($t, this.v, this.nm, record);
8419
+ } else {
8420
+ this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
8421
+ }
8422
+ });
8423
+ }
8424
+ grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
8425
+ } else {
8426
+ grp.counters[i].cnt += 1;
8427
+ grp.groups[grp.counters[i].pos].cnt = grp.counters[i].cnt;
8428
+ if(grp.groupSummary[i]) {
8429
+ $.each(grp.counters[i].summary,function() {
8430
+ if ($.isFunction(this.st)) {
8431
+ this.v = this.st.call($t, this.v, this.nm, record);
8432
+ } else {
8433
+ this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
8434
+ }
8435
+ });
8436
+ grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
8437
+ }
8438
+ }
8439
+ }
8353
8440
  }
8354
- });
8441
+ }
8355
8442
  }
8443
+ gdata.push( rData );
8356
8444
  });
8357
8445
  return gdata;
8358
8446
  },
@@ -8360,9 +8448,11 @@ $.jgrid.extend({
8360
8448
  this.each(function(){
8361
8449
  var $t = this,
8362
8450
  grp = $t.p.groupingView,
8363
- strpos = hid.lastIndexOf('_'),
8364
- uid = hid.substring(0,strpos+1),
8365
- num = parseInt(hid.substring(strpos+1),10)+1,
8451
+ strpos = hid.split('_'),
8452
+ //uid = hid.substring(0,strpos+1),
8453
+ num = parseInt(strpos[strpos.length-2], 10);
8454
+ strpos.splice(strpos.length-2,2);
8455
+ var uid = strpos.join("_"),
8366
8456
  minus = grp.minusicon,
8367
8457
  plus = grp.plusicon,
8368
8458
  tar = $("#"+$.jgrid.jqID(hid)),
@@ -8370,7 +8460,7 @@ $.jgrid.extend({
8370
8460
  tarspan = $("#"+$.jgrid.jqID(hid)+" span."+"tree-wrap-"+$t.p.direction),
8371
8461
  collapsed = false;
8372
8462
  if( tarspan.hasClass(minus) ) {
8373
- if(grp.showSummaryOnHide && grp.groupSummary[0]) {
8463
+ if(grp.showSummaryOnHide) {
8374
8464
  if(r){
8375
8465
  while(r) {
8376
8466
  if($(r).hasClass('jqfoot') ) { break; }
@@ -8381,7 +8471,7 @@ $.jgrid.extend({
8381
8471
  } else {
8382
8472
  if(r){
8383
8473
  while(r) {
8384
- if($(r).attr('id') ==uid+String(num) ) { break; }
8474
+ if( $(r).hasClass(uid+"_"+String(num) ) || $(r).hasClass(uid+"_"+String(num-1))) { break; }
8385
8475
  $(r).hide();
8386
8476
  r = r.nextSibling;
8387
8477
  }
@@ -8392,7 +8482,7 @@ $.jgrid.extend({
8392
8482
  } else {
8393
8483
  if(r){
8394
8484
  while(r) {
8395
- if($(r).attr('id') ==uid+String(num) ) { break; }
8485
+ if($(r).hasClass(uid+"_"+String(num)) || $(r).hasClass(uid+"_"+String(num-1)) ) { break; }
8396
8486
  $(r).show();
8397
8487
  r = r.nextSibling;
8398
8488
  }
@@ -8409,73 +8499,97 @@ $.jgrid.extend({
8409
8499
  return this.each(function(){
8410
8500
  var $t = this,
8411
8501
  grp = $t.p.groupingView,
8412
- str = "", icon = "", hid, pmrtl = grp.groupCollapse ? grp.plusicon : grp.minusicon, gv, cp, ii;
8413
- //only one level for now
8414
- if(!grp.groupDataSorted) {
8415
- // ???? TO BE IMPROVED
8416
- grp.sortitems[0].sort();
8417
- grp.sortnames[0].sort();
8418
- if(grp.groupOrder[0].toLowerCase() == 'desc')
8419
- {
8420
- grp.sortitems[0].reverse();
8421
- grp.sortnames[0].reverse();
8422
- }
8423
- }
8502
+ str = "", icon = "", hid, clid, pmrtl = grp.groupCollapse ? grp.plusicon : grp.minusicon, gv, cp=[], ii, len =grp.groupField.length;
8424
8503
  pmrtl += " tree-wrap-"+$t.p.direction;
8425
8504
  ii = 0;
8426
- while(ii < colspans) {
8427
- if($t.p.colModel[ii].name == grp.groupField[0]) {
8428
- cp = ii;
8429
- break;
8505
+ $.each($t.p.colModel, function (i,n){
8506
+ for(var ii=0;ii<len;ii++) {
8507
+ if(grp.groupField[ii] === n.name ) {
8508
+ cp[ii] = i;
8509
+ break;
8510
+ }
8511
+ }
8512
+ });
8513
+ var toEnd = 0;
8514
+ function findGroupIdx( ind , offset, grp) {
8515
+ if(offset===0) {
8516
+ return grp[ind];
8517
+ } else {
8518
+ var id = grp[ind].idx;
8519
+ if(id===0) { return grp[ind]; }
8520
+ for(var i=ind;i >= 0; i--) {
8521
+ if(grp[i].idx === id-offset) {
8522
+ return grp[i];
8523
+ }
8524
+ }
8430
8525
  }
8431
- ii++;
8432
8526
  }
8433
- $.each(grp.sortitems[0],function(i,n){
8434
- hid = $t.p.id+"ghead_"+i;
8527
+ var sumreverse = grp.groupSummary;
8528
+ sumreverse.reverse();
8529
+ $.each(grp.groups,function(i,n){
8530
+ toEnd++;
8531
+ clid = $t.p.id+"ghead_"+n.idx;
8532
+ hid = clid+"_"+i;
8435
8533
  icon = "<span style='cursor:pointer;' class='ui-icon "+pmrtl+"' onclick=\"jQuery('#"+$.jgrid.jqID($t.p.id)+"').jqGrid('groupingToggle','"+hid+"');return false;\"></span>";
8436
8534
  try {
8437
- gv = $t.formatter(hid, grp.sortnames[0][i], cp, grp.sortitems[0] );
8535
+ gv = $t.formatter(hid, n.value, cp[n.idx], n.value );
8438
8536
  } catch (egv) {
8439
- gv = grp.sortnames[0][i];
8440
- }
8441
- str += "<tr id=\""+hid+"\" role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+"\"><td colspan=\""+colspans+"\">"+icon+$.jgrid.format(grp.groupText[0], gv, grdata[n].length)+"</td></tr>";
8442
- for(var kk=0;kk<grdata[n].length;kk++) {
8443
- str += grdata[n][kk].join('');
8444
- }
8445
- if(grp.groupSummary[0]) {
8446
- var hhdr = "";
8447
- if(grp.groupCollapse && !grp.showSummaryOnHide) {
8448
- hhdr = " style=\"display:none;\"";
8449
- }
8450
- str += "<tr"+hhdr+" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
8451
- var fdata = grp.summaryval[0][n],
8452
- cm = $t.p.colModel,
8453
- vv, grlen = grdata[n].length;
8454
- for(var k=0; k<colspans;k++) {
8455
- var tmpdata = "<td "+$t.formatCol(k,1,'')+">&#160;</td>",
8456
- tplfld = "{0}";
8457
- $.each(fdata,function(){
8458
- if(this.nm == cm[k].name) {
8459
- if(cm[k].summaryTpl) {
8460
- tplfld = cm[k].summaryTpl;
8461
- }
8462
- if(this.st == 'avg') {
8463
- if(this.v && grlen > 0) {
8464
- this.v = (this.v/grlen);
8537
+ gv = n.value;
8538
+ }
8539
+ str += "<tr id=\""+hid+"\" 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>";
8540
+ var leaf = len-1 === n.idx;
8541
+ if( leaf ) {
8542
+ var gg = grp.groups[i+1];
8543
+ var end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length;
8544
+ for(var kk=n.startRow;kk<end;kk++) {
8545
+ str += grdata[kk].join('');
8546
+ }
8547
+ var jj;
8548
+ if (gg !== undefined) {
8549
+ for (jj = 0; jj < grp.groupField.length; jj++) {
8550
+ if (gg.dataIndex === grp.groupField[jj]) {
8551
+ break;
8552
+ }
8553
+ }
8554
+ toEnd = grp.groupField.length - jj;
8555
+ }
8556
+ for (var ik = 0; ik < toEnd; ik++) {
8557
+ if(!sumreverse[ik]) { continue; }
8558
+ var hhdr = "";
8559
+ if(grp.groupCollapse && !grp.showSummaryOnHide) {
8560
+ hhdr = " style=\"display:none;\"";
8561
+ }
8562
+ str += "<tr"+hhdr+" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
8563
+ var fdata = findGroupIdx(i, ik, grp.groups),
8564
+ cm = $t.p.colModel,
8565
+ vv, grlen = fdata.cnt;
8566
+ for(var k=0; k<colspans;k++) {
8567
+ var tmpdata = "<td "+$t.formatCol(k,1,'')+">&#160;</td>",
8568
+ tplfld = "{0}";
8569
+ $.each(fdata.summary,function(){
8570
+ if(this.nm === cm[k].name) {
8571
+ if(cm[k].summaryTpl) {
8572
+ tplfld = cm[k].summaryTpl;
8465
8573
  }
8574
+ if(this.st.toLowerCase() === 'avg') {
8575
+ if(this.v && grlen > 0) {
8576
+ this.v = (this.v/grlen);
8577
+ }
8578
+ }
8579
+ try {
8580
+ vv = $t.formatter('', this.v, k, this);
8581
+ } catch (ef) {
8582
+ vv = this.v;
8583
+ }
8584
+ tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
8585
+ return false;
8466
8586
  }
8467
- try {
8468
- vv = $t.formatter('', this.v, k, this);
8469
- } catch (ef) {
8470
- vv = this.v;
8471
- }
8472
- tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
8473
- return false;
8474
- }
8475
- });
8476
- str += tmpdata;
8587
+ });
8588
+ str += tmpdata;
8589
+ }
8590
+ str += "</tr>";
8477
8591
  }
8478
- str += "</tr>";
8592
+ toEnd = jj;
8479
8593
  }
8480
8594
  });
8481
8595
  $("#"+$.jgrid.jqID($t.p.id)+" tbody:first").append(str);
@@ -8486,14 +8600,14 @@ $.jgrid.extend({
8486
8600
  groupingGroupBy : function (name, options ) {
8487
8601
  return this.each(function(){
8488
8602
  var $t = this;
8489
- if(typeof(name) == "string") {
8603
+ if(typeof(name) === "string") {
8490
8604
  name = [name];
8491
8605
  }
8492
8606
  var grp = $t.p.groupingView;
8493
8607
  $t.p.grouping = true;
8494
8608
 
8495
8609
  //Set default, in case visibilityOnNextGrouping is undefined
8496
- if (typeof grp.visibiltyOnNextGrouping == "undefined") {
8610
+ if (typeof grp.visibiltyOnNextGrouping === "undefined") {
8497
8611
  grp.visibiltyOnNextGrouping = [];
8498
8612
  }
8499
8613
  var i;
@@ -8515,7 +8629,7 @@ $.jgrid.extend({
8515
8629
  groupingRemove : function (current) {
8516
8630
  return this.each(function(){
8517
8631
  var $t = this;
8518
- if(typeof(current) == 'undefined') {
8632
+ if(typeof(current) === 'undefined') {
8519
8633
  current = true;
8520
8634
  }
8521
8635
  $t.p.grouping = false;
@@ -8535,33 +8649,59 @@ $.jgrid.extend({
8535
8649
  });
8536
8650
  },
8537
8651
  groupingCalculations : {
8538
- "sum" : function(v, field, rc) {
8539
- return parseFloat(v||0) + parseFloat((rc[field]||0));
8540
- },
8541
- "min" : function(v, field, rc) {
8542
- if(v==="") {
8543
- return parseFloat(rc[field]||0);
8652
+ handler: function(fn, v, field, round, roundType, rc) {
8653
+ var funcs = {
8654
+ sum: function() {
8655
+ return parseFloat(v||0) + parseFloat((rc[field]||0));
8656
+ },
8657
+
8658
+ min: function() {
8659
+ if(v==="") {
8660
+ return parseFloat(rc[field]||0);
8661
+ }
8662
+ return Math.min(parseFloat(v),parseFloat(rc[field]||0));
8663
+ },
8664
+
8665
+ max: function() {
8666
+ if(v==="") {
8667
+ return parseFloat(rc[field]||0);
8668
+ }
8669
+ return Math.max(parseFloat(v),parseFloat(rc[field]||0));
8670
+ },
8671
+
8672
+ count: function() {
8673
+ if(v==="") {v=0;}
8674
+ if(rc.hasOwnProperty(field)) {
8675
+ return v+1;
8676
+ } else {
8677
+ return 0;
8678
+ }
8679
+ },
8680
+
8681
+ avg: function() {
8682
+ // the same as sum, but at end we divide it
8683
+ // so use sum instead of duplicating the code (?)
8684
+ return funcs.sum();
8685
+ }
8544
8686
  }
8545
- return Math.min(parseFloat(v),parseFloat(rc[field]||0));
8546
- },
8547
- "max" : function(v, field, rc) {
8548
- if(v==="") {
8549
- return parseFloat(rc[field]||0);
8687
+
8688
+ if(!funcs[fn]) {
8689
+ throw ("jqGrid Grouping No such method: " + fn);
8550
8690
  }
8551
- return Math.max(parseFloat(v),parseFloat(rc[field]||0));
8552
- },
8553
- "count" : function(v, field, rc) {
8554
- if(v==="") {v=0;}
8555
- if(rc.hasOwnProperty(field)) {
8556
- return v+1;
8557
- } else {
8558
- return 0;
8691
+ var res = funcs[fn]();
8692
+
8693
+ if (round != null) {
8694
+ if (roundType == 'fixed')
8695
+ res = res.toFixed(round);
8696
+ else {
8697
+ var mul = Math.pow(10, round);
8698
+
8699
+ res = Math.round(res * mul) / mul;
8700
+ }
8559
8701
  }
8560
- },
8561
- "avg" : function(v, field, rc) {
8562
- // the same as sum, but at end we divide it
8563
- return parseFloat(v||0) + parseFloat((rc[field]||0));
8564
- }
8702
+
8703
+ return res;
8704
+ }
8565
8705
  }
8566
8706
  });
8567
8707
  })(jQuery);
@@ -10105,11 +10245,13 @@ addSubGrid : function( pos, sind ) {
10105
10245
  return false;
10106
10246
  });
10107
10247
  }
10108
- if(ts.p.subGridOptions.expandOnLoad === true) {
10109
- $(ts.rows[i].cells[pos]).trigger('click');
10110
- }
10111
10248
  i++;
10112
10249
  }
10250
+ if(ts.p.subGridOptions.expandOnLoad === true) {
10251
+ $(ts.rows).filter('.jqgrow').each(function(index,row){
10252
+ $(row.cells[0]).click();
10253
+ });
10254
+ }
10113
10255
  ts.subGridXml = function(xml,sid) {subGridXml(xml,sid);};
10114
10256
  ts.subGridJson = function(json,sid) {subGridJson(json,sid);};
10115
10257
  });
@@ -11702,7 +11844,7 @@ hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function()
11702
11844
  op = $.extend({},op,opts.formatoptions);
11703
11845
  }
11704
11846
  if(!$.fmatter.isEmpty(cellval)) {
11705
- return $.fmatter.util.DateFormat(op.newformat,cellval,op.srcformat,op);
11847
+ return $.fmatter.util.DateFormat(op.newformat,cellval,op.srcformat,op);
11706
11848
  } else {
11707
11849
  return $.fn.fmatter.defaultFormat(cellval, opts);
11708
11850
  }
@@ -1,6 +1,6 @@
1
1
  /*Grid*/
2
- .ui-jqgrid {position: relative; font-size:11px;}
3
- .ui-jqgrid .ui-jqgrid-view {position: relative;left:0px; top: 0px; padding: .0em;}
2
+ .ui-jqgrid {position: relative;}
3
+ .ui-jqgrid .ui-jqgrid-view {position: relative;left:0px; top: 0px; padding: .0em; font-size:11px;}
4
4
  /* caption*/
5
5
  .ui-jqgrid .ui-jqgrid-titlebar {padding: .3em .2em .2em .3em; position: relative; border-left: 0px none;border-right: 0px none; border-top: 0px none;}
6
6
  .ui-jqgrid .ui-jqgrid-title { float: left; margin: .1em 0 .2em; }
@@ -48,7 +48,7 @@ tr.ui-search-toolbar select {margin: 1px 0px 0px 0px}
48
48
  .ui-jqgrid tr.footrow-ltr td {text-align:left;border-right-width: 1px; border-right-color: inherit; border-right-style: solid;}
49
49
  .ui-jqgrid tr.footrow-rtl td {text-align:right;border-left-width: 1px; border-left-color: inherit; border-left-style: solid;}
50
50
  /* Pager*/
51
- .ui-jqgrid .ui-jqgrid-pager { border-left: 0px none !important;border-right: 0px none !important; border-bottom: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;}
51
+ .ui-jqgrid .ui-jqgrid-pager { border-left: 0px none !important;border-right: 0px none !important; border-bottom: 0px none !important; margin: 0px !important; padding: 0px !important; position: relative; height: 25px;white-space: nowrap;overflow: hidden;font-size:11px;}
52
52
  .ui-jqgrid .ui-pager-control {position: relative;}
53
53
  .ui-jqgrid .ui-pg-table {position: relative; padding-bottom:2px; width:auto; margin: 0em;}
54
54
  .ui-jqgrid .ui-pg-table td {font-weight:normal; vertical-align:middle; padding:1px;}
@@ -78,7 +78,7 @@ tr.ui-search-toolbar select {margin: 1px 0px 0px 0px}
78
78
  .ui-jqgrid .ui-subgrid td.subgrid-cell {border-width: 0px 0px 1px 0px;}
79
79
  .ui-jqgrid .ui-th-subgrid {height:20px;}
80
80
  /* loading */
81
- .ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important;}
81
+ .ui-jqgrid .loading {position: absolute; top: 45%;left: 45%;width: auto;z-index:101;padding: 6px; margin: 5px;text-align: center;font-weight: bold;display: none;border-width: 2px !important; font-size:11px;}
82
82
  .ui-jqgrid .jqgrid-overlay {display:none;z-index:100;}
83
83
  * html .jqgrid-overlay {width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}
84
84
  * .jqgrid-overlay iframe {position:absolute;top:0;left:0;z-index:-1;width: expression(this.parentNode.offsetWidth+'px');height: expression(this.parentNode.offsetHeight+'px');}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jqgrid-jquery-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.3.0
4
+ version: 4.4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doc Walker