angular-deckgrid icon indicating copy to clipboard operation
angular-deckgrid copied to clipboard

Update angular-deckgrid.js to support filtering

Open andremann opened this issue 10 years ago • 4 comments

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 https://github.com/akoenig/angular-deckgrid/issues/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..

andremann avatar Jun 26 '15 10:06 andremann

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

svennela avatar Jul 16 '15 23:07 svennela

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.

andremann avatar Jul 17 '15 08:07 andremann

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.

kevinclchung avatar Sep 08 '15 22:09 kevinclchung

Thanks @kevinclchung !

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

andremann avatar Sep 09 '15 07:09 andremann