Skip to content

Commit 164bf38

Browse files
retain CSS while editing table
1 parent dd69771 commit 164bf38

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

js/render-datatables.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@
66
// so that we know which charts belong to our library.
77
var rendered_charts = [];
88

9+
// save the settings corresponding to cssClassNames so that when a table is being edited, they stripes etc. don't get reset
10+
var cssClassNames;
11+
912
function renderChart(id, v) {
10-
renderSpecificChart(id, all_charts[id], v);
13+
var chart = all_charts[id];
14+
if(chart.library !== 'datatables'){
15+
return;
16+
}
17+
cssClassNames = null;
18+
renderSpecificChart(id, chart, v);
1119
}
1220

1321
function renderSpecificChart(id, chart, v) {
@@ -29,7 +37,7 @@
2937
if($('#' + id).find('table.visualizer-data-table').length > 0){
3038
$('#' + id).empty();
3139
}
32-
40+
3341
settings = {
3442
destroy: true,
3543
paging: false,
@@ -89,8 +97,13 @@
8997

9098
var stripe = ['', ''];
9199

100+
if(cssClassNames !== null){
101+
chart.settings['cssClassNames'] = cssClassNames;
102+
}
103+
92104
// in preview mode, cssClassNames will not exist when a color is changed.
93105
if(typeof chart.settings['cssClassNames'] !== 'undefined'){
106+
cssClassNames = chart.settings['cssClassNames'];
94107
if(typeof chart.settings['cssClassNames']['oddTableRow'] !== 'undefined'){
95108
stripe[0] = chart.settings['cssClassNames']['oddTableRow'];
96109
}
@@ -246,7 +259,7 @@
246259
if(typeof visualizer !== 'undefined'){
247260
// called while updating the chart.
248261
visualizer.update = function(){
249-
renderChart('canvas', visualizer);
262+
renderSpecificChart('canvas', all_charts['canvas'], visualizer);
250263
};
251264
}
252265

0 commit comments

Comments
 (0)