ngx-datatable icon indicating copy to clipboard operation
ngx-datatable copied to clipboard

Issue when mixing row groups and horizontal scroll

Open shinobiwarrior opened this issue 7 years ago • 11 comments

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior

If you have row grouping and horizontal scrollbar enabled at the same time, it generates an infinite scrolling, adding blank space to the right.

Expected behavior

The table should scroll only the actual width

Reproduction of the problem

http://plnkr.co/edit/QpQthGIGIreYTZOH42Tn

What is the motivation / use case for changing the behavior?

I want to group the rows, and also be able to scroll horizontally

Please tell us about your environment:

Debian 8, VS Code, Angular CLI

  • Table version: 10.3.0 on my pc, 11.1.3 on the plunkr
  • Angular version: 4.2.4
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ] Chrome 62, Firefox 52
  • Language: [all | TypeScript X.X | ES6/7 | ES5] TS 2.5.3

shinobiwarrior avatar Nov 23 '17 02:11 shinobiwarrior

I am having this issue as well. @shinobiwarrior Were you able to solve this?

unstephenk avatar Nov 28 '17 20:11 unstephenk

Not yet, I'm still waiting for an answer here, and as I had a lot of work on my other projects, I couldn't spend time on this

shinobiwarrior avatar Nov 29 '17 02:11 shinobiwarrior

ok. I am busy as well. I will leave it like this until I get a chance to look at it.

unstephenk avatar Dec 01 '17 19:12 unstephenk

I am also facing this issue. any update on this ?

pssubashps avatar Dec 13 '17 10:12 pssubashps

Nothing on my side...

shinobiwarrior avatar Dec 13 '17 20:12 shinobiwarrior

bug

Same here 😢

Not sure but problem could be in header.component.ts (also in body-row.component.ts):

 calcStylesByGroup(group: string): any {
    const widths = this._columnGroupWidths;
    const offsetX = this.offsetX;

    const styles = {
      width: `${widths[group]}px`
    };

    if (group === 'center') {
      translateXY(styles, offsetX * -1, 0);
    } else if (group === 'right') {
      const totalDiff = widths.total - this.innerWidth;
      const offset = totalDiff * -1;
      translateXY(styles, offset, 0);
    }

    return styles;
  }

I saw, that offsetX does not have limit value, e.g. totalDiff?

chalecki avatar Jan 25 '18 11:01 chalecki

Same problem here

ClleaR avatar Jan 26 '18 14:01 ClleaR

It not best solution but it work for me.

In component.html

.
.
.
  <ngx-datatable
    #myTable
    class="bootstrap expandable"
    [rows]="dataList"
    [groupRowsBy]="'group'"
    [rowHeight]="'auto'"
    [columns]="columns"
    [loadingIndicator]="loading"
    [scrollbarH]="true"
    [groupExpansionDefault]="false"
  >

   <ngx-datatable-group-header [rowHeight]="50" #myGroupHeader >
      <ng-template let-group="group" let-expanded="expanded" ngx-datatable-group-header-template>
        <div style="padding-left: -15px;">
          <a
            [class.datatable-icon-right]="!expanded"
            [class.datatable-icon-down]="expanded"
            title="Expand/Collapse Group"
            (click)="toggleExpandGroup(group)">
            <b>{{group.value[0].group}}</b>
          </a>
        </div>
      </ng-template>
    </ngx-datatable-group-header>
.
.
.

In component.ts

@ViewChild('myTable') table: any;

public onToggleExpandGroup(group) {
 
    setTimeout(() => {
      this.table.bodyComponent.scroller.scrollWidth = this.table.bodyComponent.innerWidth;
    }, 500)

    this.table.groupHeader.toggleExpandGroup(group);
 }

baozakelka avatar Jul 25 '19 07:07 baozakelka

Hi is there a way to fix this? I still get this problem and I noticed it still occurs even on the swimlane site for the row grouping table example. @kaluginserg

AllynVo avatar Apr 21 '20 16:04 AllynVo

Hai i'm facing same ,any updates on this issue

vivek050495 avatar Aug 16 '22 09:08 vivek050495

I'm having the same issue with grouping and scrollx: true. After several tries, i found out this solution :

Use the .wrap tag in jquery to append a div with overflow-x: scroll to your table in the InitComplete function

var tableSettings = {
            dom: "Blfrtip",
            ... (All other settings)
            initComplete: function () {
                $('#productRefundCostTable').wrap('<div style="overflow-x: scroll;">');
            }
        };

edugal-parkland avatar Nov 23 '22 19:11 edugal-parkland