Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

where did setColumns go? #40

Closed
ctung opened this issue Jun 12, 2018 · 3 comments
Closed

where did setColumns go? #40

ctung opened this issue Jun 12, 2018 · 3 comments

Comments

@ctung
Copy link

ctung commented Jun 12, 2018

I used to use getColumns()/setColumns() to get/set the visible columns as a subset of the full list of columns.

It looks like I can still use angularGrid.pluginService._grid.setColumns() & ._grid.getColumns() but I don't see that documented anywhere. Also it causes inconsistencies in other variables like visibleColumns and areVisibleColumnsDifferent.

https://stackblitz.com/edit/angular-cjiajg

angularGridReady(angularGrid: AngularGridInstance) {
this.angularGrid = angularGrid;
console.log(angularGrid.gridStateService.getColumns()); // returns []
this.angularGrid.gridStateService.resetColumns(this.columnView); // does nothing?
console.log(angularGrid.pluginService._grid.getColumns()); // returns original columns
this.angularGrid.pluginService._grid.setColumns(this.columnView); // changes columns
console.log(angularGrid.pluginService.areVisibleColumnDifferent); // false should be true
console.log(angularGrid.pluginService._grid.getColumns()); // returns the partial list
}

@ghiscoding
Copy link
Owner

ghiscoding commented Jun 12, 2018

Maybe the Migration Guide is not clear enough but if you look at the Example code, you will see that the best way to get the grid and/or the dataView object is through the new AngularGridInstance. I tried to expose most of everything in that new instance.

I updated the Migration Guide

Like this way:

angularGridReady(angularGrid: AngularGridInstance) {
    this.angularGrid = angularGrid;
    this.gridObj = angularGrid.slickGrid;
    this.dataViewObj = angularGrid.dataView;

    // and any other Services you wish to use
    this.gridService = angularGrid.gridService;
}

Please don't use any _grid, they are meant to be for internal usage only.

@ghiscoding
Copy link
Owner

BTW I'm not sure what you are trying to do with the code, but aren't you looking for a Grid State & Presets functionality? The Wiki - Grid State & Presets was updated after the new 1.x version. Also the Grid State now also deal with the columns, that is new in version 1.x. So you might want to take another look at the wiki.

It's also a lot of work for 1 person (me), so if you feel that the examples, wikis are lacking then feel free to mention which wiki should be updated. Our team decided to make it open source, in the hope of bringing feedback and improvement, I think it's going good so far.

@ctung
Copy link
Author

ctung commented Jun 12, 2018

Ok, Thanks again!

@ctung ctung closed this as completed Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants