mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Better row limiting by using CSS instead of grid's average height
This commit is contained in:
parent
a6bb56d2e1
commit
904bc8b19f
@ -1875,7 +1875,7 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
this.resize();
|
||||
// Reset height to auto (after width resize) so there's no restrictions
|
||||
this.dynheight.innerNode.css('height', 'auto');
|
||||
|
||||
|
||||
// Check for rows that aren't loaded yet, or lots of rows
|
||||
var range = this.controller._grid.getIndexRange();
|
||||
this.old_height = this.controller._grid._scrollHeight;
|
||||
@ -1953,30 +1953,20 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
defer.reject();
|
||||
return;
|
||||
}
|
||||
if(value < total)
|
||||
{
|
||||
// Set height to the requested number of rows, using the average height.
|
||||
// We add one, in case there's some larger rows we
|
||||
// try to get most of it but that's pretty hacky
|
||||
nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (value+1));
|
||||
}
|
||||
// Use CSS to hide all but the requested rows
|
||||
// Prevents us from showing more than requested, if actual height was less than average
|
||||
nm.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
|
||||
egw.css(nm.print_row_selector, 'display: none');
|
||||
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
|
||||
// Grid needs to redraw before it can be printed, so wait
|
||||
window.setTimeout(jQuery.proxy(function() {
|
||||
dialog.destroy();
|
||||
|
||||
if(value < total)
|
||||
{
|
||||
// Show requested number, based on average height
|
||||
nm.controller._grid.setScrollHeight(nm.controller._grid.getAverageHeight() * (value));
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
}
|
||||
|
||||
// Should be OK to print now
|
||||
defer.resolve();
|
||||
},nm),ET2_GRID_INVALIDATE_TIMEOUT);
|
||||
@ -1991,7 +1981,15 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
else
|
||||
{
|
||||
// Don't need more rows, limit to requested and finish
|
||||
this.controller._grid.setScrollHeight(this.controller._grid.getAverageHeight() * (value));
|
||||
|
||||
// Show it all
|
||||
$j('.egwGridView_scrollarea',this.div).css('height','auto');
|
||||
|
||||
// Use CSS to hide all but the requested rows
|
||||
// Prevents us from showing more than requested, if actual height was less than average
|
||||
this.print_row_selector = ".egwGridView_grid > tbody > tr:not(:nth-child(-n+"+value+"))";
|
||||
egw.css(this.print_row_selector, 'display: none');
|
||||
|
||||
// No scrollbar in print view
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','hidden');
|
||||
// Give dialog a chance to close, or it will be in the print
|
||||
@ -2017,10 +2015,29 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput, et2_IPrin
|
||||
}
|
||||
// Don't return anything, just work normally
|
||||
},
|
||||
|
||||
/**
|
||||
* Try to clean up the mess we made getting ready for printing
|
||||
* in beforePrint()
|
||||
*/
|
||||
afterPrint: function() {
|
||||
|
||||
this.div.removeClass('print');
|
||||
|
||||
// Put scrollbar back
|
||||
$j('.egwGridView_scrollarea',this.div).css('overflow-y','');
|
||||
|
||||
// Correct size of grid, and trigger resize to fix it
|
||||
this.controller._grid.setScrollHeight(this.old_height);
|
||||
delete this.old_height;
|
||||
|
||||
// Remove CSS rule hiding extra rows
|
||||
if(this.print_row_selector)
|
||||
{
|
||||
egw.css(this.print_row_selector, false);
|
||||
delete this.print_row_selector;
|
||||
}
|
||||
|
||||
this.dynheight.outerNode.css('max-width','inherit');
|
||||
this.resize();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user