Skip to content

Is it possible to implement nested uiScroll? #346

Open
@tradingproject19

Description

@tradingproject19

Hello,

First of all thank you for this awesome library, we have migrated our source from angular virtual scroller to this library.

Everything seems to be working fine, we have one page where we have nested data,

Following is the structure of our data source.

public rooms: Array<{ name: string; isChecked: boolean, defs: WalkthroughDeficiency[] }> = [];

following is the html template:

<div [style.height.px]="contentHeight" style="overflow-y:auto">
    <div *uiScroll="let room of datasource">
      <ion-list-header *ngIf="room" color="secondary" class="ion-no-margin ion-no-padding">
        <ion-label class="ion-no-margin ion-margin-vertical ion-text-center">{{room.name}}</ion-label>
      </ion-list-header>
      <ion-item *ngFor="let def of room.defs" class="ion-no-padding ion-no-margin no-padding" lines="none">
        <ion-label class="ion-no-margin ion-margin-vertical ion-text-center">{{def.room}}</ion-label>
      </ion-item>
    </div>
  </div>

and following is the code for intializing the data source.

ngOnInit() {
this.datasource = new Datasource({
      get: (index, count, success) => {
        const data = [];
        const start = Math.max(0, index); // or 0
        const end = index + count - 1;
        if (start <= end) {
          for (let i = start; i <= end; i++) {
            if (!this.helper.isNullOrUndefined(this.rooms[i]))
              data.push(this.rooms[i]);
          }
        }
        success(data);
      },
      settings: {
        minIndex: 0,
        startIndex: 0,
        bufferSize: 5,

      },
      devSettings: {
        debug: true,
        immediateLog: true,
      }
    });
}

Is there a way to use uiScroll with room.defs, or can I extend the datasource and create my own datasource, passing the roomCode so that its get method can receive the roomCode and filter based on the roomCode as well?

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions