cancel
Showing results for 
Search instead for 
Did you mean: 

Child Selection on Parent Selection in Tree Table

0 Kudos

Hi,

I am using a tree table with multi-selection.

My requirement is: on click of parent checkbox, child's checkbox should get selected automatically.

Can it be configured in tree table or we need to do JavaScript coding?

Thanks,

Vinayak.

Accepted Solutions (0)

Answers (3)

Answers (3)

I was facing same issue. because I was using Treetable in a fragment. I have used these codes and it worked.

Controller:

in the top of the controller:

function addSelectedFlag(aNodes, bSelected) { jQuery.each(aNodes, function(iIndex, oNode) { oNode.selected = bSelected; if (oNode.categories) { addSelectedFlag(oNode.categories, bSelected); } }); }

onSelect: function(oEvent) { 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(); },

View:

<m:Tree id="TreeTableBasic" items="{path:'/questiontree/troubleshooting', parameters: {arrayNames:['categories']}}" mode="MultiSelect" selectionChange="onSelect" ariaLabelledBy="title" includeItemInSelection="true"> <m:StandardTreeItem title="{name} {code}" selected="{selected}"/>

</m:Tree>

junwu
Active Contributor

I think you need to code

sandroramos
Active Participant
0 Kudos

Try using addSelectionInterval or setSelectionInterval method of TreeTable, If you want to orverride previous selections use second option.

Check methods descriptions

addSelectionInterval: SAPUI5 SDK - Demo Kit

setSelecionInterval: SAPUI5 SDK - Demo Kit

Regards,

Sandro Ramos