Skip to content

Commit

Permalink
fix tr attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
thehitechpanky committed Apr 21, 2020
1 parent fc75b33 commit c157775
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Bootstrap

# CDN

<script src="https://cdn.jsdelivr.net/gh/TaxHeal-in/[email protected].7/html.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TaxHeal-in/[email protected].7/table.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TaxHeal-in/[email protected].8/html.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TaxHeal-in/[email protected].8/table.js"></script>

# How to use

Expand Down
24 changes: 11 additions & 13 deletions table.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,25 @@ class DynamicTable {

_addTableDataRowsFromObject() {
let { dataRows, addFilter, addLimit } = this.paramObject;
let { className, data, id } = dataRows;
let filterTerm;
if (addFilter) {
filterTerm = this.filterNode.value.toLowerCase();
}
let serialNumber = 0;
let limitNumber = 0;
let rowNode;
if (data) {
data.forEach(currentRow => {
if (!addFilter || this._filterData(filterTerm, currentRow)) {
serialNumber++;
if (!addLimit || this.limitNode.value === `all` || this.limitNode.value >= serialNumber) {
limitNumber++;
rowNode = this._getNode(`tr`, { className, id });
this.bodyNode.appendChild(rowNode);
this._addData(rowNode, serialNumber, currentRow, `td`, serialNumber);
}
dataRows.forEach(currentRow => {
let { className, data, id } = currentRow;
if (!addFilter || this._filterData(filterTerm, currentRow.data)) {
serialNumber++;
if (!addLimit || this.limitNode.value === `all` || this.limitNode.value >= serialNumber) {
limitNumber++;
rowNode = this._getNode(`tr`, { className, id });
this.bodyNode.appendChild(rowNode);
this._addData(rowNode, serialNumber, currentRow.data, `td`, serialNumber);
}
});
}
}
});
this._clearNode(this.countNode);
let textNode = document.createTextNode(`Showing 1 to ${limitNumber} of ${serialNumber} entries`);
this.countNode.appendChild(textNode);
Expand Down

0 comments on commit c157775

Please sign in to comment.