cancel
Showing results for 
Search instead for 
Did you mean: 

Selecting all child node in tree table

0 Kudos

Hi,

I am facing issue like when selecting the parent node all the child node which are targeting to respective parent node has to be selected automatically.

How it can possible ?

Accepted Solutions (1)

Accepted Solutions (1)

SergioG_TX
Active Contributor
0 Kudos

if you are using the tree table control from ui5.. there is no simple select all or even expand all.. you have to go into each level... and expandContext (or select) ... if you are using mvc binding... then you would capture the check/uncheck at the parent.. and set the children level objects to the same value. using a binding expression will be easier than having to get/set values per item

amel_saidani
Participant

Hello,

It has been more than one year but can you please help with more details.

How can we capture check/uncheck parents ?

Thank you.

Answers (1)

Answers (1)

Srikar
Active Participant

Use the below code to make child selected when a parent gets selected.

	function addSelectedFlag(aNodes, bSelected) {
				jQuery.each(aNodes, function(iIndex, oNode) {
					oNode.selected = bSelected;
					if (oNode.categories) {
						addSelectedFlag(oNode.categories, bSelected);
					}
				});
			}
			var aItems = oEvent.getParameter("listItems") || [],
				oModel = this.getView().getModel();
			jQuery.each(aItems, function(iIndex, oItem) {
				var oNode = oItem.getBindingContext().getObject(),
					bSelected = oItem.getSelected();
				if (oNode.categories) {
					addSelectedFlag(oNode.categories, bSelected);
				}
			});
			oModel.refresh();