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

Add a way to use filters in tree view #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "angular.treeview",
"homepage": "https://github.com/luisalvarez/angular.treeview",
"_release": "e72dd58723",
"_resolution": {
"type": "branch",
"branch": "master",
"commit": "e72dd587233fa392e7da8e6e58622d61a100fa24"
},
"_source": "https://github.com/luisalvarez/angular.treeview.git",
"_target": "*",
"_originalSource": "https://github.com/luisalvarez/angular.treeview.git",
"_direct": true
}
15 changes: 12 additions & 3 deletions angular.treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
node-id : each node's id
node-label : each node's label
node-children: each node's children
data-node-filter: filter to search


<div
data-angular-treeview="true"
data-tree-id="tree"
data-tree-model="roleList"
data-node-id="roleId"
data-node-label="roleName"
data-node-children="children" >
data-node-children="children"
data-node-filter="filter">
</div>
*/

Expand All @@ -44,15 +47,21 @@
//children
var nodeChildren = attrs.nodeChildren || 'children';

//filter
var nodeFilter =attrs.nodeFilter || '';
var filter=null;
if(nodeFilter!==''){
filter=' | filter: ' + nodeFilter;
}
//tree template
var template =
'<ul>' +
'<li data-ng-repeat="node in ' + treeModel + '">' +
'<li data-ng-repeat="node in ' + treeModel + filter+'">' +
'<i class="collapsed" data-ng-show="node.' + nodeChildren + '.length && node.collapsed" data-ng-click="' + treeId + '.selectNodeHead(node)"></i>' +
'<i class="expanded" data-ng-show="node.' + nodeChildren + '.length && !node.collapsed" data-ng-click="' + treeId + '.selectNodeHead(node)"></i>' +
'<i class="normal" data-ng-hide="node.' + nodeChildren + '.length"></i> ' +
'<span data-ng-class="node.selected" data-ng-click="' + treeId + '.selectNodeLabel(node)">{{node.' + nodeLabel + '}}</span>' +
'<div data-ng-hide="node.collapsed" data-tree-id="' + treeId + '" data-tree-model="node.' + nodeChildren + '" data-node-id=' + nodeId + ' data-node-label=' + nodeLabel + ' data-node-children=' + nodeChildren + '></div>' +
'<div data-ng-hide="node.collapsed" data-tree-id="' + treeId + '" data-tree-model="node.' + nodeChildren + '" data-node-id=' + nodeId + ' data-node-label=' + nodeLabel + ' data-node-children=' + nodeChildren + ' data-node-filter='+nodeFilter+'></div>' +
'</li>' +
'</ul>';

Expand Down
13 changes: 7 additions & 6 deletions angular.treeview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.