We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Grid on route change does not show data just empty rows


Normally I always binded the data in the constructor:

export class AdminComponent {
parentKey: any;
childdatasource

constructor(
public firebase: AngularFireDatabase,
private fns: AngularFireFunctions,
private firebasedb: FirebaseService,
private toast: HotToastService
) {
firebase
.list('/main')
.valueChanges()
.subscribe((users) => {
this.storeExpandedIndexes();
this.mainGrid.dataSource = users; //intial data binding to grid

});

firebase
.list('/main')
.snapshotChanges()
.subscribe((users) => {
this.storeExpandedIndexes();
this.mainGrid.dataSource = users; // sync server data changes to grid

});
}


But when moving between routes I get empty data rows rendering in.

The way I find to solve this is to add another initial data binding in the ngoninit


ngOnInit(): void {

this.firebase
.list('/main')
.valueChanges()
.subscribe((users) => {
this.storeExpandedIndexes();
this.mainGrid.dataSource = users; //intial data binding to grid

});

}


but I can not remove it from the constructor because then it breaks on page refresh and does the same issue.

Is there a bit more of an elegant way to make sure data binds at the correct time instead of me adding .valuechanges() to both constructor and ngonint?












1 Reply

JC Joseph Christ Nithin Issack Syncfusion Team April 27, 2023 07:17 PM UTC

Hi Frank,


Greetings from Syncfusion support.


We tried to reproduce the issue you are facing but we were not able to reproduce the issue from our side. Please share the below details for further validation of the issue.


  1. Kindly share us the entire grid code snippet.
  2. Video demo of the issue replication.
  3. Share us the simple issue reproducible sample to us or
  4. Syncfusion package version you are using.


Regards,

Joseph I.



Loader.
Up arrow icon