1- # angular-tree-table
2- [ Angular 1.x] Display tree table & ; event DrapnDrop, field 'td' by tree (other normal) - without jQuery.
1+ # angular-tree-dnd
2+ [ Angular 1.x] Display tree dnd & ; event DrapnDrop, field 'td' by tree (other normal) - without jQuery.
33## Current Version
4- [ ![ GitHub version] ( https://badge.fury.io/gh/thienhung1989%2Fangular-tree-table .svg )] ( http://badge.fury.io/gh/thienhung1989%2Fangular-tree-table )
4+ [ ![ GitHub version] ( https://badge.fury.io/gh/thienhung1989%2Fangular-tree-dnd .svg )] ( http://badge.fury.io/gh/thienhung1989%2Fangular-tree-dnd )
55
66## Demo:
7- - http://thienhung1989.github.io/angular-tree-table /demo
7+ - http://thienhung1989.github.io/angular-tree-dnd /demo
88- http://plnkr.co/edit/6zQNvW?p=preview
99
1010
1111## Install bower:
1212``` js
13- bower angular- tree- table install
13+ bower angular- tree- dnd install
1414```
1515
1616* Function 'filter' & 'group by' not add in ng-repeate (it's slow & incompatible with $id($$hash) )
17- * Able add function to tree-table by:
17+ * Able add function to tree-dnd by:
1818 * Example: *(See on Demo 2)*
1919``` js
2020 $scope .my_tree .addFunction = function (b ){
2121 console .log (b);
2222 alert (' Function added in Controller "App.js"' );
2323 }
2424```
25- * Call function: *(tree.remove_branch extended see below with function other)*
25+ * Call function: *(tree.remove_node extended see below with function other)*
2626``` js
2727 $scope .col_defs = [
2828 {
2929 field: " Description"
3030 }, {
3131 displayName: ' Function' ,
32- cellTemplate: ' <button ng-click="tree.addFunction(row )" class="btn btn-default btn-sm">Added Controller!</button>'
32+ cellTemplate: ' <button ng-click="tree.addFunction(node )" class="btn btn-default btn-sm">Added Controller!</button>'
3333 }, {
3434 displayName: ' Remove' ,
35- cellTemplate: ' <button ng-click="tree.remove_branch(row )" class="btn btn-default btn-sm">Remove</button>'
35+ cellTemplate: ' <button ng-click="tree.remove_node(node )" class="btn btn-default btn-sm">Remove</button>'
3636 }];
3737```
3838
@@ -72,60 +72,60 @@ $scope.$callbacks = {
7272``` html
7373 tree.expand_all();
7474 tree.collapse_all();
75- tree.select_first_branch ();
76- tree.select_branch(branch );
77- tree.add_branch (parent, new_branch , index);
78- tree.add_root_branch(new_branch );
79- tree.remove_branch(branch );
80- tree.expand_branch(branch );
81- tree.collapse_branch(branch );
82- tree.get_selected_branch ();
83- tree.get_first_child(branch );
84- tree.get_children(branch );
85- tree.get_first_branch ();
86- tree.get_next_branch(branch );
87- tree.get_prev_branch(branch );
88- tree.get_parent_branch(branch );
89- tree.get_siblings(branch );
90- tree.get_next_sibling(branch );
91- tree.get_prev_sibling(branch );
92- tree.get_closest_ancestor_next_sibling(branch );
93- tree.select_next_branch(branch );
94- tree.select_next_sibling(branch );
95- tree.select_prev_sibling(branch );
96- tree.select_parent_branch(branch );
97- tree.last_descendant(branch );
98- tree.select_prev_branch(branch );
75+ tree.select_first_node ();
76+ tree.select_node(node );
77+ tree.add_node (parent, new_node , index);
78+ tree.add_root_node(new_node );
79+ tree.remove_node(node );
80+ tree.expand_node(node );
81+ tree.collapse_node(node );
82+ tree.get_selected_node ();
83+ tree.get_first_child(node );
84+ tree.get_children(node );
85+ tree.get_first_node ();
86+ tree.get_next_node(node );
87+ tree.get_prev_node(node );
88+ tree.get_parent_node(node );
89+ tree.get_siblings(node );
90+ tree.get_next_sibling(node );
91+ tree.get_prev_sibling(node );
92+ tree.get_closest_ancestor_next_sibling(node );
93+ tree.select_next_node(node );
94+ tree.select_next_sibling(node );
95+ tree.select_prev_sibling(node );
96+ tree.select_parent_node(node );
97+ tree.last_descendant(node );
98+ tree.select_prev_node(node );
9999```
100100
101101* Example
102102** init:
103103``` html
104- <tree-table
105- class =" table "
104+ <tree-dnd
105+ class =" dnd "
106106 tree-data =" tree_data"
107107 tree-control =" my_tree"
108108 callbacks =" callbacks"
109109 drag-enabled =" true"
110110 icon-leaf =" none"
111111 icon-expand =" fa fa-fw fa-angle-right"
112112 icon-collapse =" fa fa-fw fa-angle-down"
113- template-url =" tree-table -template.html"
113+ template-url =" tree-dnd -template.html"
114114 column-defs =" col_defs"
115115 expand-on =" expanding_property"
116- on-select =" my_tree_handler(branch )"
117- on-click =" my_tree_handler(branch )"
116+ on-select =" my_tree_handler(node )"
117+ on-click =" my_tree_handler(node )"
118118 data-indent =" 30"
119119 data-indent-unit =" px"
120120 data-indent-plus =" 15"
121121 >
122- </tree-table >
122+ </tree-dnd >
123123```
124124** Template Extened:
125125``` html
126- <script type =" text/ng-template" id =" tree-table -template.html" >
127- <div class =" tree-table " >
128- <table class =" table " >
126+ <script type =" text/ng-template" id =" tree-dnd -template.html" >
127+ <div class =" tree-dnd " >
128+ <dnd class =" dnd " >
129129 <thead >
130130 <tr >
131131 <th ng-class =" expandingProperty.titleClass" ng-style =" expandingProperty.titleStyle" >
@@ -138,27 +138,27 @@ $scope.$callbacks = {
138138 </tr >
139139 </thead >
140140 <tbody >
141- <tr tree-table -node ng-repeat =" row in tree_rows track by hashedTree(row )"
142- ng-show =" row .__visible__" ng-class =" (row .__selected__ ? ' active':'')"
141+ <tr tree-dnd -node ng-repeat =" node in tree_rows track by hashedTree(node )"
142+ ng-show =" node .__visible__" ng-class =" (node .__selected__ ? ' active':'')"
143143 class =" ng-animate " >
144144 <td ng-if =" !expandingProperty.template"
145- ng-style =" expandingProperty.cellStyle ? expandingProperty.cellStyle : {'padding-left': $callbacks.calsIndent(row .__level__)}"
146- ng-click =" user_clicks_branch(row )" ng-class =" expandingProperty.cellClass"
145+ ng-style =" expandingProperty.cellStyle ? expandingProperty.cellStyle : {'padding-left': $callbacks.calsIndent(node .__level__)}"
146+ ng-click =" user_clicks_node(node )" ng-class =" expandingProperty.cellClass"
147147 compile =" expandingProperty.cellTemplate" >
148- <span tree-table -node-handle >
148+ <span tree-dnd -node-handle >
149149 <i class =" fa fa-sort text-muted m-r-sm" ></i >
150- </span > {{row [expandingProperty.field] || row [expandingProperty]}} <a > <i
151- ng-class =" row .__tree_icon__" ng-click =" row .__expanded__ = !row .__expanded__"
150+ </span > {{node [expandingProperty.field] || node [expandingProperty]}} <a > <i
151+ ng-class =" node .__tree_icon__" ng-click =" node .__expanded__ = !node .__expanded__"
152152 class =" tree-icon" ></i > </a >
153153 </td >
154154 <td ng-if =" expandingProperty.template" compile =" expandingProperty.template" ></td >
155155 <td ng-repeat =" col in colDefinitions" ng-class =" col.cellClass" ng-style =" col.cellStyle"
156156 compile =" col.cellTemplate" >
157- {{row [col.field]}}
157+ {{node [col.field]}}
158158 </td >
159159 </tr >
160160 </tbody >
161- </table >
161+ </dnd >
162162 </div >
163163 <pre >{{ treeData | json }}</pre >
164164 <pre >{{ tree_rows | json }}</pre >
@@ -211,10 +211,10 @@ $scope.$callbacks = {
211211 * pass: bypass resutl in `$callback.beforeDrop:`.
212212 * isMove: status Moving or Copying.
213213
214- * Add 'data' to TreeTableNode ` tree-table -node=data ` in template;
214+ * Add 'data' to TreeDnDNode ` tree-dnd -node=data ` in template;
215215``` html
216- <tr tree-table -node =" row " ng-repeat =" row in tree_rows track by hashedTree(row )"
217- ng-show =" row .__visible__" ng-class =" (row .__selected__ ? ' active':'')" class =" ng-animate " >
216+ <tr tree-dnd -node =" node " ng-repeat =" node in tree_rows track by hashedTree(node )"
217+ ng-show =" node .__visible__" ng-class =" (node .__selected__ ? ' active':'')" class =" ng-animate " >
218218 ....
219219</tr >
220220```
@@ -224,58 +224,58 @@ $scope.$callbacks = {
224224* Combinding with list-tree.
225225
226226``` html
227- <script type =" text/ng-template" id =" tree-table -template-render.html" >
228- <ul tree-table -nodes =" tree_data" >
229- <li tree-table -node =" row " ng-repeat =" row in datas track by row .__hashKey__"
230- ng-show =" row .__visible__" compile =" expandingProperty.cellTemplate"
231- ng-include =" 'tree-table -template-fetch.html'" ></li >
227+ <script type =" text/ng-template" id =" tree-dnd -template-render.html" >
228+ <ul tree-dnd -nodes =" tree_data" >
229+ <li tree-dnd -node =" node " ng-repeat =" node in datas track by node .__hashKey__"
230+ ng-show =" node .__visible__" compile =" expandingProperty.cellTemplate"
231+ ng-include =" 'tree-dnd -template-fetch.html'" ></li >
232232 </ul >
233233 </script >
234234
235- <script type =" text/ng-template" id =" tree-table -template-fetch.html" >
235+ <script type =" text/ng-template" id =" tree-dnd -template-fetch.html" >
236236 <div class =" list-group-item"
237- ng-class =" (row .__selected__ ? 'list-group-item-success':'')"
238- ng-click =" onClick(row )"
237+ ng-class =" (node .__selected__ ? 'list-group-item-success':'')"
238+ ng-click =" onClick(node )"
239239 ng-style =" expandingProperty.cellStyle ? expandingProperty.cellStyle : {}" >
240240
241- <a class =" btn btn-default" aria-label =" Justify" type =" button" tree-table -node-handle >
241+ <a class =" btn btn-default" aria-label =" Justify" type =" button" tree-dnd -node-handle >
242242 <span class =" glyphicon glyphicon-align-justify" aria-hidden =" true" ></span >
243243 </a >
244244
245- {{row [expandingProperty.field] || row [expandingProperty]}}
245+ {{node [expandingProperty.field] || node [expandingProperty]}}
246246
247- <span ng-class =" $iconClass" ng-click =" toggleExpand(row )" ></span >
247+ <span ng-class =" $iconClass" ng-click =" toggleExpand(node )" ></span >
248248 <div class =" pull-right" >
249249 <span ng-repeat =" col in colDefinitions" ng-class =" col.cellClass" ng-style =" col.cellStyle"
250250 compile =" col.cellTemplate" >
251- {{row [col.field]}}
251+ {{node [col.field]}}
252252 </span >
253253 </div >
254254 </div >
255- <ul tree-table -nodes =" row .__children__" >
256- <li tree-table -node =" row " ng-repeat =" row in datas track by row .__hashKey__"
257- ng-show =" row .__visible__" compile =" expandingProperty.cellTemplate"
258- ng-include =" 'tree-table -template-fetch.html'" ></li >
255+ <ul tree-dnd -nodes =" node .__children__" >
256+ <li tree-dnd -node =" node " ng-repeat =" node in datas track by node .__hashKey__"
257+ ng-show =" node .__visible__" compile =" expandingProperty.cellTemplate"
258+ ng-include =" 'tree-dnd -template-fetch.html'" ></li >
259259 </ul >
260260 </script >
261261
262- <tree-table tree-data =" tree_data"
262+ <tree-dnd tree-data =" tree_data"
263263 tree-control =" my_tree"
264264 column-defs =" col_defs_min"
265265 expand-on =" expanding_property"
266- on-select =" select_handler(branch )"
267- on-click =" click_handler(branch )"
268- template-url =" tree-table -template-render.html"
266+ on-select =" select_handler(node )"
267+ on-click =" click_handler(node )"
268+ template-url =" tree-dnd -template-render.html"
269269 icon-leaf =" none"
270270 icon-expand =" glyphicon glyphicon-chevron-down"
271271 icon-collapse =" glyphicon glyphicon-chevron-right"
272- ></tree-table >
272+ ></tree-dnd >
273273```
274274
275275
276276## Add attributes
277277 * `__tree_icon__` : changed to `__icon__` *(-1: leaf, 0: collect, 1: expaned)* - *(in Tree_Data)*
278- * Added `$iconClass` replace for `__tree_icon__` *(avoid conflict when create tree-table use one `tree-data`)*
278+ * Added `$iconClass` replace for `__tree_icon__` *(avoid conflict when create tree-dnd use one `tree-data`)*
279279 * Add function:
280280 * re-Add function `dropped` in `$callbaks` *(used to copying or remove node old)*:
281281 *
@@ -305,7 +305,7 @@ $scope.$callbacks = {
305305 * 'template-move': to add url template of `Status Move` *(can bypass string or variable in controller, but just only get $templateCache, if not exist will get default)*;
306306 * Example:
307307``` html
308- <tree-table class =" tree-table table table -hover b-b b-light" tree-data =" tree_data" tree-control =" my_tree"
308+ <tree-dnd class =" tree-dnd dnd dnd -hover b-b b-light" tree-data =" tree_data" tree-control =" my_tree"
309309 primary-key =" primaryKey"
310310 callbacks =" callbacks"
311311
@@ -323,15 +323,15 @@ $scope.$callbacks = {
323323 on-select =" select_handler()"
324324 on-click =" click_handler()"
325325
326- template-url =" tree-table -template.html"
327- template-move =" 'tree-table -template.html'"
328- template-copy =" tree-table -template.html"
326+ template-url =" tree-dnd -template.html"
327+ template-move =" 'tree-dnd -template.html'"
328+ template-copy =" tree-dnd -template.html"
329329
330330 data-indent =" 30"
331331 data-indent-unit =" px"
332332 data-indent-plus =" 15"
333333
334- ></tree-table >
334+ ></tree-dnd >
335335
336336```
337337
0 commit comments