Forums

Home » Alloy UI » English

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Mohammad Azharuddin
Aui Tree View -Get all selected value in a tree view
June 9, 2014 11:51 AM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 502

Join Date: September 17, 2012

Recent Posts

Hi all how to get all selected checkbox value of child in a tree view...?
I can able to get the last selected checkbox value
And how to set value for a checkBox
 1
 2<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
 3<div id="myTreeView" style="border-right:1px solid #D9DADB;"></div>
 4<aui:script>
 5
 6
 7AUI().use(
 8          'aui-tree-view',
 9          function(A) {
10            new A.TreeViewDD(
11              {
12                boundingBox: '#myTreeView',
13                children: [
14                  {
15                    children: [
16                      {label: 'Learn Spanish', leaf: true, type: 'task'},
17                      {label: 'Learn Salesforce', leaf: true, type: 'task'},
18                      {label: 'Hibernate Course', leaf: true,  type: 'task'},
19                      {label: 'Finance & Magaement', leaf: true, type: 'task'},
20                      {label: 'More', leaf: true, type: 'task' , color: 'blue'}
21                     
22                    ],
23                    expanded: true,
24                    label: 'Title',
25                    type: 'task'
26                  }
27                ],
28                after: {
29            lastSelectedChange: function(event){
30            alert("LAST SELECTED VALUE-->"+event.newVal.get('label'));
31                    }
32                }
33              }
34            ).render();
35          }
36        );            
37
38</aui:script>
Mohammad Azharuddin
RE: Aui Tree View -Get all selected value in a tree view
June 9, 2014 9:10 PM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 502

Join Date: September 17, 2012

Recent Posts

HI all

Any solution...?
Meera Prince
RE: Aui Tree View -Get all selected value in a tree view
June 9, 2014 11:10 PM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

Hi

Find the parent element which wrap the all check box values

try as follows


A.all('input').each(function (node) {
if (node.getAttribute('checked')==''checked') {

}
});

reference

http://www.jsrosettastone.com/
Mohammad Azharuddin
RE: Aui Tree View -Get all selected value in a tree view
June 10, 2014 2:39 AM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 502

Join Date: September 17, 2012

Recent Posts

Hi prince Unable to get the result..Is that is working for you...?
I notice that there is no cheked attribute in that check box and when i check the check box class tree-node-checked append to the parent div
Mohammad Azharuddin
RE: Aui Tree View -Get all selected value in a tree view
June 10, 2014 3:25 AM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 502

Join Date: September 17, 2012

Recent Posts

HI meera

I can able to get if the node is checked(node.get('checked')) but unable to get the other details about the node ie (node.get('label'))

A.all('input').each(function (node) {
alert(node.get('label')+" Is checked--"+node.get('checked'));

});
Meera Prince
RE: Aui Tree View -Get all selected value in a tree view
June 11, 2014 7:00 PM
Answer

Meera Prince

Rank: Liferay Legend

Posts: 1110

Join Date: February 8, 2011

Recent Posts

Hi

The check box have label attribute then only it can give man i guess label is not attribute for check box ok.

type , value, name, id are the attributes if you want then you can use your custom attribute as follows i.e. label for your check box.

Like

<input type="checkbox" label="checkbox1" value=""/>


Try this

1A.one('#parentNodeWrappedAllCheckBoxes').all('input[type=checkbox]').each(function (node) {
2  if (node.getAttribute('checked')=='checked') {
3    alert(node.getAttribute('label'))
4  }
5});


in your case label is not an attribute of check box ok

Regards,
meera prince
Mohammad Azharuddin
RE: Aui Tree View -Get all selected value in a tree view
June 11, 2014 9:32 AM
Answer

Mohammad Azharuddin

Rank: Liferay Master

Posts: 502

Join Date: September 17, 2012

Recent Posts

Hi Prince It is working

Below is the working code for two events...We can use either one and lastSelectedChange event sometime not working if i check and uncheck parent check box ...


 1
 2<%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%>
 3<div id="myTreeView" style="border-right: 1px solid #D9DADB;"></div>
 4<aui:script>
 5
 6
 7AUI().use(
 8          'aui-tree-view',
 9          function(A) {
10            var treeView=new A.TreeViewDD(
11              { 
12                  boundingBox: '#myTreeView',
13                children: [
14                  {
15                    children: [
16                      {label: 'Learn Spanish', leaf: true, type: 'task',id: '11'},
17                      {label: 'Learn Salesforce', leaf: true, type: 'task',id: '12'},
18                      {label: 'Hibernate Course', leaf: true,  type: 'task',id: '13'},
19                      {label: 'Finance & Magaement',leaf: true, type: 'task', id: '14'},
20                      {label: 'More', leaf: true, type: 'task' ,id: '15'}
21                     
22                    ],
23                    expanded: true,
24                    label: 'Title',
25                    type: 'task'
26                  }
27                ]
28               
29              }).render();
30          
31          
32            treeView.on('click', function(event){
33            alert("on click event");
34             getCheckedElement(treeView);
35            });
36            
37            
38            treeView.after("lastSelectedChange", function(event) {
39            alert("after lastSelectedChange event");
40             getCheckedElement(treeView);
41            
42             });
43            
44            
45        });
46       
47            Liferay.provide(
48            window,
49            'getCheckedElement',
50            function(product_configurator_tree) {
51                 var nodeList = new Array();
52                nodeList = product_configurator_tree.getChildren(true);
53                var attrNodeObj = "";
54                for( var i = 0 ; i < nodeList.length ; i++){
55                alert(nodeList[i].isChecked()+"---------"+nodeList[i].get("label"));
56                }
57            });
58</aui:script>
Madasamy P
RE: Aui Tree View -Get all selected value in a tree view
December 29, 2016 3:36 AM
Answer

Madasamy P

Rank: Junior Member

Posts: 73

Join Date: July 27, 2016

Recent Posts

Am I give the label as one variable name contains String value and I want to use loops in tree structure
Madasamy P
RE: Aui Tree View -Get all selected value in a tree view
December 29, 2016 4:00 AM
Answer

Madasamy P

Rank: Junior Member

Posts: 73

Join Date: July 27, 2016

Recent Posts

I want looping to displays the muliple file names as label

What can I do for it?