Last active
August 9, 2017 19:25
-
-
Save Xanmia/f88c3344eb9acf810616eae7c4c074a2 to your computer and use it in GitHub Desktop.
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
.scroll-window:before{ | |
content:""; | |
position: absolute; | |
width:100%; | |
height:2.5rem; | |
display: table; | |
z-index: 98; | |
background:rgba(170,170,170,1.0); | |
} |
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
function buildTable(data, tableOpts) { | |
var columns, columnKeys, headingRow, c, cLen, column, header, key; | |
var style = tableOpts.css || { margin: '0 auto' }; | |
// var headerTable = $('<table class="header-table"/>').css(style); | |
var dataTable= $('<table class="data-table"/>').css(style); | |
columns = tableOpts.columns; | |
columnKeys = Object.keys(columns); | |
tableOpts.columnKeys = columnKeys; | |
headingRow = $('<tr style="height:2.5rem;"/>'); | |
//headerTable.append(headingRow); | |
for (c = 0, cLen = columnKeys.length; c < cLen; c++) { | |
key = columnKeys[c]; | |
column = columns[key]; | |
column.name = key; | |
header = $('<th/>').html(column.heading); | |
header.append($('<div style="position:absolute; margin-top: -2.25rem; z-index:99;color:333;"/>').html(column.heading).css(column.css || TD_CSS)); | |
if (column.sortable) { | |
header.on('click', function() { | |
sortTable(dataTable, data, this, tableOpts); | |
}); | |
} | |
headingRow.append(header); | |
} | |
dataTable.append(headingRow); | |
createTableRows(dataTable, data, tableOpts); | |
return $('<div style="position:relative;"/>').append($('<div class="scroll-window" style="max-height:300px; overflow-y:auto;"/>').append(dataTable)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment