Skip to content

Commit 13b699a

Browse files
add horizontal scrolling
1 parent 5454722 commit 13b699a

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ protected function _renderTableSettings() {
202202
)
203203
);
204204

205+
self::_renderCheckboxItem(
206+
esc_html__( 'Enable Horizontal Scrolling', 'visualizer' ),
207+
'scrollX',
208+
$this->scrollX,
209+
'true',
210+
esc_html__( 'To disable wrapping of columns and enabling horizontal scrolling.', 'visualizer' )
211+
);
212+
205213
echo '<div class="viz-section-delimiter section-delimiter"></div>';
206214

207215
self::_renderCheckboxItem(

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: 16 additions & 3 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,26 +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':
5557
// remove scrollY if its greater than what will fit in the box (along with the legend).
5658
if(parseInt(chart.settings['scrollY_int']) > 180){
5759
chart.settings['scrollY_int'];
5860
}
61+
delete chart.settings['scrollX'];
5962
$.extend( settings, {
6063
scrollX: 150,
6164
scrollY: 180,
6265
} );
6366
break;
64-
case 'frontend':
6567
case 'chart':
68+
delete chart.settings['scrollX'];
69+
// fall-through.
70+
case 'frontend':
6671
// empty.
6772
break;
6873
}
6974
}
7075

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

0 commit comments

Comments
 (0)