Hello,
I am using your grid for an application and the feature I am trying to implement is to dynamically change the columns and the datasource without having to destroy the component. Here is a sample in which I was able to isolate that specific scenario https://stackblitz.com/edit/angular-gknz17-ekyjxv?file=app.component.ts. As you can see I want to be able to update the grid on some triggered event. Please observe the console for the errors.
Best
App.component.ts
addColumn(e) { //button click
this.grid.columns = [];
this.grid.dataSource = [[//set the new dataSource to the Grid’s dataSource
{ id: '1', name: 'martin' },
{ id: '1', name: 'martin' },
{ id: '1', name: 'martin' },
{ id: '1', name: 'martin' }
];
this.grid.columns = [//set the new column to the Grid’s columns property
{
field: 'id',
headerText: 'id'
},
{
field: 'name',
headerText: 'name'
}
];
}
|
Hello,
Thanks for your help. I managed to fix a issue with your suggestions.
Unfortunately, I faced common issue only when we have column virtualization enabled.
https://stackblitz.com/edit/angular-gknz17-ekyjxv?file=app.component.ts
Here in this sample you can try to click the button 'Add column' and observe that the number of the columns is correct but neither their fields/headerNames are correct, nor the data in the grid.
Hello again,
Thank you for your answer but it does not help me.
That stackblitz is just an isolated sample of what issue I am facing right now. My grid configuration consist at least 30 columns and more than 10k records. In this case I definitely do need both row and column virtualization. Here I recreated a sample where there are more columns than the columns which are in the view port. I have set the width and height of the grid but the above issue still occurs. As I said before the issue is reproduced only with column virtualization enabled.
Sample: https://stackblitz.com/edit/angular-gknz17-z4szy9?file=app.component.html
Regards,
Martin
addColumn(e) {
let a = [
{
field: 'id',
headerText: 'id'
},
{
field: 'name',
headerText: 'name'
},
{
field: 'age',
headerText: 'age'
},
{
field: 'device',
headerText: 'device'
}
];
this.grid.columns = [];
this.grid.enableColumnVirtualization = false;
this.grid.enableVirtualization = false;
this.grid.allowSorting = false;
this.grid.allowFiltering = false;
this.grid.columns = a;
this.data = [
{ id: '1', name: 'martin', age:'30', device: 'phone' },
{ id: '1', name: 'martin', age:'30', device: 'phone' },
{ id: '1', name: 'martin', age:'30', device: 'phone' },
{ id: '1', name: 'martin', age:'30', device: 'phone' }
];
this.grid.dataSource = this.data;
setTimeout(function(){
this.grid.enableColumnVirtualization = true;
this.grid.enableVirtualization = true;
this.grid.allowSorting = true;
this.grid.allowFiltering = true;
}.bind(this));
}
|
Hello,
Thank you for your help. With slight modification I managed to make it work.
Regards,
Martin