-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vis] fix pivot table scrolling when using more than 1 groupy col (#2674
) * fix scrolling when more than 1 groupby * generalize function arguments * fix pivot table scrolling in js * add padding rules back * linting
- Loading branch information
Alanna Scott
authored
Apr 25, 2017
1 parent
1df37e6
commit 0bdc301
Showing
3 changed files
with
25 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
.slice-grid .widget.pivot_table .slice_container { | ||
overflow: auto !important; | ||
} | ||
|
||
.widget.pivot_table table { | ||
margin: 0px !important; | ||
} | ||
|
||
.widget.pivot_table tr>th { | ||
padding: 1px 5px !important; | ||
font-size: small !important; | ||
} | ||
|
||
.widget.pivot_table tr>td { | ||
padding: 1px 5px !important; | ||
font-size: small !important; | ||
.widget.pivot_table tr > th, | ||
.widget.pivot_table tr > td { | ||
padding: 1px 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,41 @@ | ||
import 'datatables.net'; | ||
import dt from 'datatables.net-bs'; | ||
|
||
import $ from 'jquery'; | ||
import 'datatables-bootstrap3-plugin/media/css/datatables-bootstrap3.css'; | ||
import { fixDataTableBodyHeight } from '../javascripts/modules/utils'; | ||
|
||
const $ = require('jquery'); | ||
|
||
require('./pivot_table.css'); | ||
require('datatables-bootstrap3-plugin/media/css/datatables-bootstrap3.css'); | ||
import './pivot_table.css'; | ||
|
||
dt(window, $); | ||
|
||
module.exports = function (slice, payload) { | ||
const container = slice.container; | ||
const fd = slice.formData; | ||
const height = container.height(); | ||
|
||
// payload data is a string of html with a single table element | ||
container.html(payload.data); | ||
|
||
if (fd.groupby.length === 1) { | ||
const height = container.height(); | ||
// When there is only 1 group by column, | ||
// we use the DataTable plugin to make the header fixed. | ||
// The plugin takes care of the scrolling so we don't need | ||
// overflow: 'auto' on the table. | ||
container.css('overflow', 'hidden'); | ||
const table = container.find('table').DataTable({ | ||
paging: false, | ||
searching: false, | ||
bInfo: false, | ||
scrollY: height + 'px', | ||
scrollY: `${height}px`, | ||
scrollCollapse: true, | ||
scrollX: true, | ||
}); | ||
table.column('-1').order('desc').draw(); | ||
fixDataTableBodyHeight( | ||
container.find('.dataTables_wrapper'), height); | ||
fixDataTableBodyHeight(container.find('.dataTables_wrapper'), height); | ||
} else { | ||
// When there is more than 1 group by column we just render the table, without using | ||
// the DataTable plugin, so we need to handle the scrolling ourselves. | ||
// In this case the header is not fixed. | ||
container.css('overflow', 'auto'); | ||
container.css('height', `${height + 10}px`); | ||
} | ||
}; |