feat(tablepanel): minor progress

This commit is contained in:
Torkel Ödegaard
2015-11-03 08:18:35 +01:00
parent 8171cd51c4
commit da9c792ca2
2 changed files with 22 additions and 2 deletions

View File

@@ -58,6 +58,15 @@ export function tablePanelDirective() {
link: function(scope, elem) { link: function(scope, elem) {
var data; var data;
function getTableHeight() {
var panelHeight = scope.height || scope.panel.height || scope.row.height;
if (_.isString(panelHeight)) {
panelHeight = parseInt(panelHeight.replace('px', ''), 10);
}
return (panelHeight - 40) + 'px';
}
function renderPanel() { function renderPanel() {
var rootDiv = elem.find('.table-panel-container'); var rootDiv = elem.find('.table-panel-container');
var tableDiv = $('<table class="gf-table-panel"></table>'); var tableDiv = $('<table class="gf-table-panel"></table>');
@@ -70,8 +79,10 @@ export function tablePanelDirective() {
rowElem.append(colElem); rowElem.append(colElem);
} }
tableDiv.append(rowElem); var headElem = $('<thead></thead>');
headElem.append(rowElem);
var tbodyElem = $('<tbody></tbody>');
for (y = 0; y < data.rows.length; y++) { for (y = 0; y < data.rows.length; y++) {
row = data.rows[y]; row = data.rows[y];
rowElem = $('<tr></tr>'); rowElem = $('<tr></tr>');
@@ -79,9 +90,14 @@ export function tablePanelDirective() {
colElem = $('<td>' + row[i] + '</td>'); colElem = $('<td>' + row[i] + '</td>');
rowElem.append(colElem); rowElem.append(colElem);
} }
tableDiv.append(rowElem); tbodyElem.append(rowElem);
} }
tableDiv.append(headElem);
tableDiv.append(tbodyElem);
rootDiv.css({'max-height': getTableHeight()});
rootDiv.empty(); rootDiv.empty();
rootDiv.append(tableDiv); rootDiv.append(tableDiv);
} }

View File

@@ -7,6 +7,10 @@
} }
} }
.table-panel-container {
overflow: auto;
}
.gf-table-panel* { .gf-table-panel* {
box-sizing: border-box; box-sizing: border-box;
} }