EE / angular-ui-tree-filter

A module providing an AngularJS filter which can be used with angular-ui-tree to match tree nodes.
ee.github.io/angular-ui-tree-filter
MIT License
40 stars 21 forks source link

issue with filtering at child level #5

Closed smart987 closed 9 years ago

smart987 commented 9 years ago

Angularjs UI tree filtering feature is not working at child level however it is working fine at group level. For example if we type node1 or node2 filtering works fine, but if we type node1.2 or node2.1, filtering won't work properly. Please find http://plnkr.co/edit/paTTL33sOffTGJJxC3j5?p=preview.

If I add the following code to my script.js file everything is scrapping out. So I have commented that part in my plunker.

jrencz commented 9 years ago

The first thing I noticed is that you commented out the trust filter. Whether or not this is a good way to disable SCE (it is not due to the lack of content escaping) it's required if you want to use highlighting.

The couse of this issue is that you're using a different descendant collection field than than the default, which is items

A solution for your problem will be to add

.config(function (uiTreeFilterSettingsProvider) {
    uiTreeFilterSettingsProvider.descendantCollectionField = 'nodes';
})

to your module

smart987 commented 9 years ago

Thanks jrencz, when I change nodes to items it is working fine. Regarding commenting trust filter part, actually I want to use highlighting feature but when I UN-comment that trust filter part the whole application is scrapping out and nothing is working, that is the reason I have commented part. I don't know why? Is there any fix for that for me to use that highlighting.

jrencz commented 9 years ago

What you do now is redeclaring your app module:

angular.module('folderApp', ['ui.tree',  'ui.tree-filter',  'ui.highlight']).filter('trust', function () {});

Try declaring the filter in your app module. There are 2 ways: by reference:

angular.module('folderApp').filter('trust', function () {});

and directly:

angular
    .module('folderApp', [/*deps*/])
    .controller('folderCtrl', function () {})
    .filter('trust', function () {});
jeremypeters commented 8 years ago

Just a quick comment - if a different descendant collection field other than the default items is being used (e.g.nodes), the uiTreeFilterSettingsProvider property to update in the config is descendantCollection, not descendantCollectionField as stated in a reply above.