Skip to content

Commit

Permalink
fix working of setGroupHeaders if grid inside of hidden div (inactive…
Browse files Browse the repository at this point in the history
… jQuery UI Tab, for example)

Thanks @davgino (https://github.com/davgino) for the bug report! See [the issue](#230).
  • Loading branch information
OlegKi committed May 5, 2016
1 parent e44ec41 commit 4867fce
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions js/grid.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@
}, o || {});
return this.each(function () {
this.p.groupHeader = o;
var ts = this, i, cmi, skip = 0, $tr, $colHeader, th, $th, thStyle, iCol, cghi, numberOfColumns, titleText, cVisibleColumns,
var ts = this, i, cmi, skip = 0, $tr, $colHeader, th, $th, thStyle, iCol, cghi, numberOfColumns, titleText, cVisibleColumns, cColumns,
p = ts.p, colModel = p.colModel, cml = colModel.length, ths = ts.grid.headers, $theadInTable, thClasses,
$htable = $("table.ui-jqgrid-htable", ts.grid.hDiv), isCellClassHidden = jgrid.isCellClassHidden,
$trLabels = $htable.children("thead").children("tr.ui-jqgrid-labels"),
Expand Down Expand Up @@ -1073,8 +1073,9 @@
titleText = cghi.titleText;

// caclulate the number of visible columns from the next numberOfColumns columns
for (cVisibleColumns = 0, iCol = 0; iCol < numberOfColumns && (i + iCol < cml); iCol++) {
if (!colModel[i + iCol].hidden && !isCellClassHidden(colModel[i + iCol].classes) && !$(ths[i + iCol].el).is(":hidden")) {
for (cVisibleColumns = 0, iCol = 0, cColumns = 0; iCol < numberOfColumns && (i + iCol < cml); iCol++) {
cColumns++;
if (!colModel[i + iCol].hidden && !isCellClassHidden(colModel[i + iCol].classes)) {
cVisibleColumns++;
}
}
Expand All @@ -1086,8 +1087,8 @@
.addClass(thClasses)
.css({ "height": "22px", "border-top": "0 none" })
.html(titleText);
if (cVisibleColumns > 0) {
$colHeader.attr("colspan", String(cVisibleColumns));
if (cColumns > 1) {
$colHeader.attr("colspan", String(cColumns));
}
if (p.headertitles) {
$colHeader.attr("title", $colHeader.text());
Expand All @@ -1106,6 +1107,11 @@
if (skip === 0) {
if (o.useColSpanStyle) {
// expand the header height to two rows
//
// !!! TODO: The value of rowspan could be too high
// in case of calling setGroupHeaders MULTIPLE times
// To calculate correct value one have to analyse the
// rows ABOVE the current one
$th.attr("rowspan", $trLabels.length + 1);
} else {
$("<th>")
Expand Down

0 comments on commit 4867fce

Please sign in to comment.