Skip to content

Commit a7204c4

Browse files
update loaded table data array on add data rows (#41)
1 parent 136c250 commit a7204c4

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

web/scripts/tableView.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function initializeView() {
127127
const scrollToLastRowButton = document.getElementById('scroll-to-last-row-button');
128128
scrollToLastRowButton.addEventListener('click', scrollToLastRow);
129129

130-
// notify webview
130+
// request initial rows data load
131131
vscode.postMessage({ command: 'refresh' });
132132
}
133133

@@ -223,16 +223,15 @@ function onTableBuilt () {
223223
console.log('tableView.columns:', columns);
224224

225225
// add row selection column
226+
// TODO: make this optional via tabular data viewer config setting
226227
table.addColumn({
227228
formatter: 'rowSelection',
228229
titleFormatter: 'rowSelection',
229230
headerMenu: [], // don't show header context menu
230231
headerSort: false,
231232
download: false // don't include it in data save
232233
}, true) // add as 1st column
233-
.then(function (column) {
234-
// column - the component for the newly created column
235-
// run code after column has been added
234+
.then(function (column) { // column - row selection colulmn component
236235
})
237236
.catch(function (error) {
238237
// log adding row selection column error for now
@@ -324,19 +323,20 @@ function clearTable(table) {
324323
}
325324

326325
/**
327-
* Adds data to the table.
326+
* Adds data rows to the table.
328327
*
329328
* @param {*} table Tabulator table instance.
330-
* @param {*} tableData Data array for the table rows.
329+
* @param {*} dataRows Data array for the table rows to add.
331330
*/
332-
function addData(table, tableData) {
333-
if (table && tableData) {
334-
table.addData(tableData, true)
331+
function addData(table, dataRows) {
332+
if (table && dataRows) {
333+
table.addData(dataRows, true)
335334
.then(function (rows) { // rows - array of the row components for the rows updated or added
336-
// update loaded rows counter
335+
// update loaded table data array and rows counter
336+
tableData.push(dataRows.shift());
337337
loadedRows += rows.length;
338338
if (loadedRows < totalRows) {
339-
// request more data to load and display
339+
// request more data rows to load and display
340340
dataPage++;
341341
progressRing.style.visibility = 'visible';
342342
vscode.postMessage({

0 commit comments

Comments
 (0)