Skip to content

Commit cafbf63

Browse files
Merge pull request #455 from contactashish13/issue-424-1
DataTables: Scrolling doesn't work properly
2 parents db015de + dd429a0 commit cafbf63

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

classes/Visualizer/Render/Sidebar/Type/DataTable/DataTable.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,24 @@ protected function _renderTableSettings() {
190190

191191
echo '<div class="viz-section-delimiter section-delimiter"></div>';
192192

193+
self::_renderTextItem(
194+
esc_html__( 'Table Height', 'visualizer' ),
195+
'scrollY_int',
196+
isset( $this->scrollY_int ) ? $this->scrollY_int : '',
197+
esc_html__( 'Height of the table in pixels (the table will show a scrollbar).', 'visualizer' ),
198+
'',
199+
'number',
200+
array(
201+
'min' => 0,
202+
)
203+
);
204+
193205
self::_renderCheckboxItem(
194-
esc_html__( 'Scroll Collapse', 'visualizer' ),
195-
'scrollCollapse_bool',
196-
$this->scrollCollapse_bool,
206+
esc_html__( 'Enable Horizontal Scrolling', 'visualizer' ),
207+
'scrollX',
208+
$this->scrollX,
197209
'true',
198-
esc_html__( 'Allow the table to reduce in height when a limited number of rows are shown', 'visualizer' )
210+
esc_html__( 'To disable wrapping of columns and enabling horizontal scrolling.', 'visualizer' )
199211
);
200212

201213
echo '<div class="viz-section-delimiter section-delimiter"></div>';

css/library.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,6 @@ button.media-modal-close {
292292
display: none !important;
293293
}
294294

295-
.dataTables_scrollBody {
296-
overflow: hidden !important;
297-
}
298-
299295
.dataTables_wrapper {
300296
max-height: 300px;
301297
overflow: hidden !important;

js/render-datatables.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
if($('#' + id).find('table.visualizer-data-table').length > 0){
3030
$('#' + id).empty();
3131
}
32-
$('#' + id).append($('<table class="dataTable visualizer-data-table table table-striped"></table>'));
33-
32+
3433
settings = {
3534
destroy: true,
3635
paging: false,
@@ -48,23 +47,40 @@
4847
dom: 'Bfrtip',
4948
};
5049

50+
var $classes = 'dataTable visualizer-data-table table table-striped';
51+
5152
if(typeof v.page_type !== 'undefined'){
5253
switch(v.page_type){
5354
case 'post':
55+
// fall-through.
5456
case 'library':
57+
// remove scrollY if its greater than what will fit in the box (along with the legend).
58+
if(parseInt(chart.settings['scrollY_int']) > 180){
59+
chart.settings['scrollY_int'];
60+
}
61+
delete chart.settings['scrollX'];
5562
$.extend( settings, {
5663
scrollX: 150,
5764
scrollY: 180,
58-
scrollCollapse: true
5965
} );
6066
break;
61-
case 'frontend':
6267
case 'chart':
68+
delete chart.settings['scrollX']; // jshint ignore:line
69+
// fall-through.
70+
case 'frontend':
6371
// empty.
6472
break;
6573
}
6674
}
6775

76+
if(typeof chart.settings['scrollX'] !== 'undefined'){
77+
if(chart.settings['scrollX'] == 'true'){ // jshint ignore:line
78+
$classes = $classes + ' nowrap';
79+
}
80+
}
81+
82+
$('#' + id).append($('<table class="' + $classes + '"></table>'));
83+
6884
var select = {
6985
info: false
7086
};

0 commit comments

Comments
 (0)