diprokon / ng-table-virtual-scroll

Virtual Scroll for Angular Material Table
https://diprokon.github.io/ng-table-virtual-scroll
MIT License
135 stars 42 forks source link

Issue with dynamic spanrow #6

Closed simyco closed 3 years ago

simyco commented 4 years ago

Hello, great work, i really appreciate this lib! i'm just facing some issuee when using in combo with dynamic spanrow When using a code like this:

<td
              mat-cell
              *matCellDef="let element; let i = index"
              [style.padding-left]="'5px'"
              [style.padding-right]="'5px'"
              [style.display]="getRowSpan(col, i) ? '' : 'none'"
              [attr.rowspan]="getRowSpan(col, i)"
            >
              <div [innerHTML]="element[col]"></div>
            </td>
spanRow(key: any, accessor: any) {
    for (let i = 0; i < this.DATA.length; ) {
      const currentValue = accessor(this.DATA[i]);
      let count = 1;

      for (let j = i + 1; j < this.DATA.length; j++) {
        if (currentValue !== accessor(this.DATA[j])) {
          break;
        }

        count++;
      }

      if (!this.spans[i]) {
        this.spans[i] = {};
      }

      this.spans[i][key] = count;
      i += count;
    }
  }

  getRowSpan(col: string | number, index: string | number) {
    return this.spans[index] && this.spans[index][col];
  }

The result in some columns is broken:

Screenshot 2020-01-25 at 09 27 17

(Buon 1980 is not spanned like the others, when not using this lib is working right)

Thanks again!

diprokon commented 4 years ago

Hi! I'm not sure, that your issue is related to this lib. Did you fix it already? If not, can you ,please, provide the full html/ts code for the component with table?

scribter commented 4 years ago

Hi, same problem when I wanne change the height with[style.height.px] dynamically.