mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Merge pull request #5677 from bmundt/remove_columns
Added Hidden Column Style for Table Panel
This commit is contained in:
@@ -39,6 +39,7 @@ export class TablePanelEditorCtrl {
|
||||
{text: 'Number', value: 'number'},
|
||||
{text: 'String', value: 'string'},
|
||||
{text: 'Date', value: 'date'},
|
||||
{text: 'Hidden', value: 'hidden'}
|
||||
];
|
||||
this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%'];
|
||||
this.dateFormats = [
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<table class="table-panel-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th ng-repeat="col in ctrl.table.columns">
|
||||
<th ng-repeat="col in ctrl.table.columns" ng-hide="col.hidden">
|
||||
<div class="table-panel-table-header-inner pointer" ng-click="ctrl.toggleColumnSort(col, $index)">
|
||||
{{col.text}}
|
||||
<span class="table-panel-table-header-controls" ng-if="col.sort">
|
||||
|
||||
@@ -45,6 +45,12 @@ export class TableRenderer {
|
||||
return this.defaultCellFormater;
|
||||
}
|
||||
|
||||
if (style.type === 'hidden') {
|
||||
return v => {
|
||||
return undefined;
|
||||
};
|
||||
}
|
||||
|
||||
if (style.type === 'date') {
|
||||
return v => {
|
||||
if (v === undefined || v === null) {
|
||||
@@ -123,6 +129,13 @@ export class TableRenderer {
|
||||
widthHack = '<div class="table-panel-width-hack">' + this.table.columns[columnIndex].text + '</div>';
|
||||
}
|
||||
|
||||
if (value === undefined) {
|
||||
style = ' style="display:none;"';
|
||||
this.table.columns[columnIndex].hidden = true;
|
||||
} else {
|
||||
this.table.columns[columnIndex].hidden = false;
|
||||
}
|
||||
|
||||
return '<td' + style + '>' + value + widthHack + '</td>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user