Skip to content

Commit 28b280d

Browse files
committed
refactored everything
1 parent 1489390 commit 28b280d

File tree

5 files changed

+414
-373
lines changed

5 files changed

+414
-373
lines changed

index.html

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,37 +18,45 @@
1818
<script type="text/javascript">
1919
/** Generate Test Data */
2020
var testData = []
21-
for(var i=0; i<100; i++) {
21+
for(var i=0; i<1000; i++) {
2222
testData.push({
23-
No1: Math.floor(100000 + Math.random() * 900000),
24-
No2: Math.floor(100000 + Math.random() * 900000),
25-
No3: Math.floor(100000 + Math.random() * 900000)
23+
No1: Math.round(Math.random() * Math.pow(10, Math.random()*10)),
24+
No2: Math.round(Math.random() * Math.pow(10, Math.random()*10)),
25+
No3: Math.round(Math.random() * Math.pow(10, Math.random()*10))
2626
})
2727
}
2828

2929
/** Table creation */
30-
var scrollableTable = new scrollableTable('scrollableTable', 'wrapper')
30+
var scrollableTable = new scrollableTable(/* unique id */ 'scrollableTable', /* HTML wrapper id */ 'wrapper', /* enable logging*/ true)
3131
scrollableTable.setTableHeader(["Number 1", "Number 2", "Number 3"])
3232
scrollableTable.setTableContent(testData, "testDataEventType", ["No1", "No2", "No3"])
3333
/* optional */ scrollableTable.setTableHeight( () => { return $( window ).height() - 166 } )
34-
// or e.g.: scrollableTable.setTableHeight(500)
34+
// or alternatively e.g.: scrollableTable.setTableHeight(500)
35+
/* optional */ scrollableTable.expandTree()
36+
// /* optional */ scrollableTable.collapseTree()
3537
/* optional */ scrollableTable.setCompareFunctionForSorting( function(a,b) {
3638
return a.localeCompare(b, undefined, {usage: 'sort', numeric: true, sensitivity: 'base'})
3739
})
3840
/* optional */ scrollableTable.sortByColumnName("Number 1")
3941

40-
/** Event processing */
41-
$( document ).on("testDataEventType", function(event, rowId) {
42-
if (rowId !== "") {
42+
43+
/**
44+
* Event processing
45+
* return: data type: {rowId: '<<STRING>>', data: {<<ORIGINAL DATA ENTRY of the selected row>>}} or null if nothing is selected
46+
*/
47+
$( document ).on("testDataEventType", function(event, data) {
48+
if (data !== null) {
4349
$('#displayArea').html(
44-
"'testDataEventType' from row with ID: "+rowId +" was triggered.\n\n"+
50+
"'testDataEventType' from row with ID: '" + data.rowId +"' was triggered.\n\n"+
4551
"Row data: \n" +
46-
JSON.stringify( testData[rowId], null, 4) )
47-
} else {
52+
JSON.stringify( data.data, null, 4) )
53+
}
54+
else {
4855
$('#displayArea').html("Chick on a row to display its content here.")
4956
}
5057
});
5158

59+
5260
function filterTable() {
5361
var filterString = $('#searchField').val()
5462
scrollableTable.filter(filterString)

0 commit comments

Comments
 (0)