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

Trying to enable enableFiltering option dynamically #2067

Closed
rubenjimenez opened this issue Nov 12, 2014 · 13 comments
Closed

Trying to enable enableFiltering option dynamically #2067

rubenjimenez opened this issue Nov 12, 2014 · 13 comments
Assignees
Milestone

Comments

@rubenjimenez
Copy link

Hi,

As the title says, I'm trying to activate the enableFiltering dinamically, but i can't and i don't know why. I can change the enableCellEdit behavior on the fly, but the same process doesn't work for enableFiltering.

I'm doing next:

var options = angular.copy($scope.gridOptions[$index]);

options.enableFiltering = true;

$scope.gridOptions[$index] = options;

for ( var i = 0, j = $scope.gridOptions[$index].columnDefs.length; i < j; i += 1 ) {
  $scope.gridOptions[$index].columnDefs[i].enableFiltering = true;
}

$scope.gridApi[$index].core.refresh();

$scope.gridOptions is an array because i'm showing a lot of grids.

What am i doing wrong?

Thanks.

@PaulL1
Copy link
Contributor

PaulL1 commented Nov 12, 2014

We need to add some specific logic to do that, and haven't is the short answer.

@PaulL1 PaulL1 added this to the 3.0 milestone Nov 12, 2014
@PaulL1 PaulL1 self-assigned this Nov 12, 2014
@PaulL1 PaulL1 changed the title Trying to enable enableFiltering option dinamically Trying to enable enableFiltering option dynamically Dec 21, 2014
@whitehat101
Copy link

👍 I would also appreciate this feature.

I believe I ran into this quirk. I'm starting with an empty dataset [] and enableFiltering: true. Once CSV data is imported, it displays the data but the filter boxes do not appear. I'm guessing this is because, at the time of grid creation there are no columns (or column headers), so it correctly makes zero filters and the code never runs again.

Is there a method we can call that will recompute some of these things?

@iooi
Copy link

iooi commented Feb 21, 2015

+1. i'd love to have this feature, as there are many scenarios that we want to toggle the filter areas

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 8, 2015

I believe this is now implemented, I think I saw someone else push the request a couple of weeks back. Can we confirm?

@ssonnenwald
Copy link

Has this been pushed out yet? Doesn't seem to be. I just pulled the latest a day ago. I know you were waiting for a response on this, but just wondering.

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 17, 2015

Sorry, I appear to have failed to merge it. Merging now.

@PaulL1 PaulL1 closed this as completed in ba304b2 Mar 17, 2015
@paambaati
Copy link

@PaulL1 Quick question. If my data is all dynamic and I've set $scope.gridOptions.enableFiltering to true, how do I set enableFiltering to false for a specific dynamic column after all the data is fetched? If I try to access $scope.gridOptions.columnDefs, it is just an empty array.

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 24, 2015

Hmm. We don't really deal with that situation. You can get the gridApi via onRegisterApi, and then modify grid.columns[x].colDef directly. I'm not sure it's a great idea, but it'd probably work and I can't think of any downsides other than it not being a documented API.

@paambaati
Copy link

@PaulL1 Thanks for the quick response. Although, when I try to do console.log(gridApi.grid); I see all the items in grid, including columns and all their colDefs. However, when I try to do console.log(gridApi.grid.columns);, I see an empty array. What gives?

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 25, 2015

Most likely timing? Has the data loaded at this point? Or try gridApi.grid.columns[0]?

@paambaati
Copy link

@PaulL1 My guess is timing too. In the success callback of my remote data fetch, I set $scope.gridOptions.data to the data, and immediately afterwards, I try to look at gridApi.grid.columns[0] and it is undefined. Is there a callback for data-load complete for ui-grid?

@PaulL1
Copy link
Contributor

PaulL1 commented Mar 25, 2015

Yes, you need a $timeout before you can look at the columns after you set the data, if you're relying on the grid to define the columns based on the data.

@W-prog
Copy link

W-prog commented Jan 2, 2017

Hi everybody,
I have the same prob and i'va resolve with defined a fake field in 1st gridOption
After, I defined the columnDef dynamically
If i don't first defined the fake field, the filter don't work. I don't know why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants