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

Update angular-deckgrid.js to support filtering #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andremann
Copy link

@andremann andremann commented Jun 26, 2015

I proposed a patch adding filtering capabilities to your great directive.
I hope it works fine for you.
As i wrote in a previous message on issue #39
Basically I injected $filter dependency in the module and used it in

Deckgrid.prototype.$$createColumns = function $$createColumns () { 
    /*...*/
    angular.forEach($filter('filter')(this.$$scope.model, this.$$scope.filter), function onIteration (card, index) { /*...*/ }
    /*...*/
}

in order to filter source attribute by a new directive attribute (called filter) for which I registered a new watcher

filterWatcher = this.$$scope.$watchCollection('filter', this.$$onModelChange.bind(this));
this.$$watchers.push(filterWatcher);

Apologies for any inconvenience.. I'm a github newbie..

I proposed a patch adding filtering capabilities to your great directive.
I hope i works fine for you.
As i wrote in a previous message on issue akoenig#39
Basically I injected `$filter` dependency in the module and used it in 
```javascript
Deckgrid.prototype.$$createColumns = function $$createColumns () { 
    /*...*/
    angular.forEach($filter('filter')(this.$$scope.model, this.$$scope.filter), function onIteration (card, index) { /*...*/ }
    /*...*/
}
```
in order to filter `source` attribute by a new directive attribute (called `filter`) for which I registered a new watcher
```javascript
filterWatcher = this.$$scope.$watchCollection('filter', this.$$onModelChange.bind(this));
this.$$watchers.push(filterWatcher);
```

Apologies for any inconvenience.. I'm a github newbie..
@andremann andremann changed the title Update angular-deckgrid.js Update angular-deckgrid.js to support filtering Jun 26, 2015
@svennela
Copy link

@andremann Do you have any samples on how to use filters? Please let me know.

@andremann
Copy link
Author

Sure! As I wrote in my last message, with my PR I introduced a new attribute to the deckgrid directive called filter.
So, in an angular view of mine, I just coded
<input type="text" class="form-control ng-pristine ng-valid" ng-model="controlsExplorer.controlFilter" placeholder="Filter by...">

and a few lines below I use such a model for filtering purposes
<div class="deckgrid" deckgrid source="controlsExplorer.controls" filter="controlsExplorer.controlFilter" cardTemplate="partials/decker-control-card.html"></div>

I hope this answers your question.

@kevinclchung
Copy link

It should be worth noting that this change would make angular-deckgrid support the standard angular filter, called "filter," and would expect an ng-model as its value (string). It would not allow it to support custom filters.

Nice work, though. Simple and clean.

@andremann
Copy link
Author

Thanks @kevinclchung !

I kept it simple as my needs were quite straightforward.
Of course it would be nice supporting custom filtering implementations.

dstran added a commit to dstran/angular-deckgrid that referenced this pull request Jul 21, 2016
Pull in PR: Update angular-deckgrid.js to support filtering akoenig#88
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

Successfully merging this pull request may close these issues.

3 participants