Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Multiple LazyLoadEvent in a form #6640


User avatar
0
kalidarscope created

I am loading multiple p-table in a form using LazyLoadEvent. First table loading Actions and second table loading sections. For example first table has no data and second table has data. It will load the empty rows in first table. The datas are not loaded properly too. I think, one LazyLoadEvent is loaded but other one loaded early. So the tables data is loading based on loaded LazyLoadEvent.

getActions(event?: LazyLoadEvent) {
        this._activatedRoute.params.subscribe((params: Params) => {
            if (params['id'] != '0') {
                this._scriptService.getScriptsForEdit(params['id']).subscribe((result) => {
                    this.filter = result.reC_ID;
                    this.primengTableHelper.showLoadingIndicator();
                    if (this.primengTableHelper.shouldResetPaging(event)) {
                        this.paginator.changePage(0);
                        return;
                    }

                    this._actionService.getActions(
                        this.filter,
                        this.primengTableHelper.getSorting(this.dataTable),
                        this.primengTableHelper.getMaxResultCount(this.paginator, event),
                        this.primengTableHelper.getSkipCount(this.paginator, event)
                    ).pipe(finalize(() => this.primengTableHelper.hideLoadingIndicator())).subscribe(result => {
                        this.primengTableHelper.totalRecordsCount = result.totalCount;
                        this.primengTableHelper.records = result.items;
                        this.primengTableHelper.hideLoadingIndicator();
                    });
                });
            }
        });
    }
getSections(event?: LazyLoadEvent) {
       
        this._activatedRoute.params.subscribe((params: Params) => {
            if (params['id'] != 'new')
            {
                this._tabService.getTabForEdit(params['id']).subscribe((result) => {
                    this.filter = result.reC_ID.toString().trim();
                    this.primengTableHelper.showLoadingIndicator();
                    if (this.primengTableHelper.shouldResetPaging(event)) {
                        this.paginator.changePage(0);
                        return;
            }

                    this._sectionService.getSections(
                        this.filter,
                        this.primengTableHelper.getSorting(this.dataTable),
                       this.primengTableHelper.getMaxResultCount(this.paginator, event),
                        this.primengTableHelper.getSkipCount(this.paginator, event)
                    ).pipe(finalize(() => this.primengTableHelper.hideLoadingIndicator())).subscribe(result => {
                        this.primengTableHelper.totalRecordsCount = result.totalCount;
                        this.primengTableHelper.records = result.items;
                        this.primengTableHelper.hideLoadingIndicator();
                    });
                });
            }
        });

    }

No answer yet!