Tuesday, March 26, 2013

How To select all childnodes on selecting a parent node

Hi
 
I am new to GWT
Developing Tree like structure with parent and child Cell having a checkbox and TextCell
want to know how to set all checkbox as selected under a Parent when Parent Item is seleted
 
I have tried SingleSelection and MultiSelectionModel
I am unable to retrieve all childs on selecting a parent Checkbox.
 
I have following doubts
 
do I need different selectionModel for parent cell and a child cell ?
how to get childobject when parent node is selected?
 
written following sample code for selection
 

//ChildNode SelectionModelfinal MultiSelectionModel<RequestNotifyDTO> selectionModel =

new MultiSelectionModel<RequestNotifyDTO>();

selectionModel.addSelectionChangeHandler(

new SelectionChangeEvent.Handler() {

public void onSelectionChange(SelectionChangeEvent event) {

StringBuilder sb = new StringBuilder();

boolean first = true;

List<RequestNotifyDTO> selected = new ArrayList<RequestNotifyDTO>(

selectionModel.getSelectedSet());

//Collections.sort(selected);

for (RequestNotifyDTO value : selected) {

if (first) {

first = false;

} else {

sb.append(", ");

}

sb.append(value.getUserName());

}

System.out.println("select value >> "+sb.toString());

}

});

//ParentNode SelectionModelfinal SingleSelectionModel<String> categorySelectionModel =

new SingleSelectionModel<String>();

categorySelectionModel.addSelectionChangeHandler(

new SelectionChangeEvent.Handler() {

public void onSelectionChange(SelectionChangeEvent event) {

Object obj=categorySelectionModel.getSelectedObject();

System.out.println("object >> "+obj);

//to do ????

}

});

 
Please assist
 
Regards

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment