I'm new to angular-gridster2, but I managed to apply some dynamic changes to my gridster's layout, so I will try to help you.
I can't see where your "options" property comes from, but it should be an instance of GridsterConfig, so the beginning of your .ts file should look like this:
import { GridsterConfig, GridsterItem } from 'angular-gridster2';
options: GridsterConfig;
Once you defined your options, you can refresh your gridster's layout by calling the api's optionsChanged method like this:
test(){
this.myAptInfolet.cols = 2;
this.options.api.optionsChanged();
}
You can refer to the angular-gridster2 github's to find a very small and clean example on how to dinamically interact with items and change the grid's layout:
import { GridsterConfig, GridsterItem } from 'angular-gridster2';
options: GridsterConfig;
dashboard: Array<GridsterItem>;
static itemChange(item, itemComponent) {
console.info('itemChanged', item, itemComponent);
}
static itemResize(item, itemComponent) {
console.info('itemResized', item, itemComponent);
}
ngOnInit() {
this.options = {
itemChangeCallback: AppComponent.itemChange,
itemResizeCallback: AppComponent.itemResize,
};
this.dashboard = [
{cols: 2, rows: 1, y: 0, x: 0},
{cols: 2, rows: 2, y: 0, x: 2}
];
}
changedOptions() {
this.options.api.optionsChanged();
}
removeItem(item) {
this.dashboard.splice(this.dashboard.indexOf(item), 1);
}
addItem() {
this.dashboard.push({});
}
I hope this can help.