fix: appendRows bug (#181)

Co-authored-by: ArunMuthuram <65416680+ArunMuthuram@users.noreply.github.com>
This commit is contained in:
Faris Ansari 2023-11-21 13:24:35 +05:30 committed by GitHub
parent 7ee8ca9304
commit b21e547794
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -21,6 +21,7 @@
<button onclick="datatable.render()">Render Table</button>
<button onclick="datatable.refresh()">Refresh Data</button>
<button onclick="switchToTreeView()" data-action="treeview">TreeView</button>
<button onclick="appendRows()">Append Rows</button>
<label>
<input type="checkbox" id="input-large-data" />
<span>Large Data</span>
@ -278,6 +279,15 @@
console.log(e)
}
};
function appendRows() {
datatable.appendRows(
[
["Garrett", "Accountant", "Tokyo", 8422, "2011/07/25", 170],
["Winters", "Accountant", "Tokyo", 8422, "2011/07/25", 123]
]
)
}
</script>
</body>

View File

@ -29,7 +29,8 @@ export default class DataManager {
this.rows = [];
this.prepareColumns();
this.prepareRows();
this.validateData(this.data);
this.rows = this.prepareRows(this.data);
this.prepareTreeRows();
this.prepareRowView();
this.prepareNumericColumns();
@ -141,10 +142,8 @@ export default class DataManager {
});
}
prepareRows() {
this.validateData(this.data);
this.rows = this.data.map((d, i) => {
prepareRows(data) {
return data.map((d, i) => {
const index = this._getNextRowCount();
let row = [];
@ -243,8 +242,9 @@ export default class DataManager {
appendRows(rows) {
this.validateData(rows);
this.rows.push(...this.prepareRows(rows));
this.rows = this.rows.concat(this.prepareRows(rows));
this.prepareTreeRows();
this.prepareRowView();
}
sortRows(colIndex, sortOrder = 'none') {