Year ago I had a blog post about workaround to render check box in ADF tree table - ADF Tree - How to Autoselect/Deselect Checkbox. This was implemented with previous JDeveloper 11g R1 PS4 version. However, there is no need to have described workaround anymore, check box and ADF tree table combination works much better in JDeveloper 11g R2 version - 11.1.2.3.0. Based on blog reader request, I will post today updated sample application - TreeCheckboxApp_v3.zip.
Both entities - Regions and Countries have special attribute of Boolean type, this attribute will be rendered as check box in ADF UI tree table component. There is no need to have helper attribute as we had before. Regions entity:
Countries entity:
Once Regions check box is checked - all Countries are checked (and vice versa). We can control this from managed bean - listening for value change event in Regions and resetting Countries:
On ADF UI side, in order to be able to render proper tree table structure with check boxes - don't forget to set rendered expression, we want to render check box only for such rows, where check box value is not Null:
Take a look how it is displayed on UI. China is selected, from Asia group:
Select Asia check box - all countries from Asia will get selected automatically (thanks to managed bean method we have implemented above):
Both entities - Regions and Countries have special attribute of Boolean type, this attribute will be rendered as check box in ADF UI tree table component. There is no need to have helper attribute as we had before. Regions entity:
Countries entity:
Once Regions check box is checked - all Countries are checked (and vice versa). We can control this from managed bean - listening for value change event in Regions and resetting Countries:
On ADF UI side, in order to be able to render proper tree table structure with check boxes - don't forget to set rendered expression, we want to render check box only for such rows, where check box value is not Null:
Take a look how it is displayed on UI. China is selected, from Asia group:
Select Asia check box - all countries from Asia will get selected automatically (thanks to managed bean method we have implemented above):
Uncheck Asia check box - all dependent check boxes are unchecked:
While Region check box is checked, you can uncheck/check Countries check box as well. This is one of the most typical use cases for check box support in ADF tree table.
Hello Andrejus!
ReplyDeleteThere is still some strange behaviour happening on that demo...
If you select a row and that correspondent checkbox after it works!
But if you directly select the checkbox you need a double click to have it checked... It happens both on parent nodes and on child nodes (tested on Firefox and Chrome).
Does it happen to you too?
Hi,
ReplyDeleteNope - this wasnt happening, when I was testing. I using latest JDev 11g.
Andrejus
I have a treetable with checkboxes where the parent and child is one viewobject. Like the employee id and manager id in the employee viewobject. How to uncheck/check all the child based on the parent uncheck/check?
ReplyDeleteI need to get the data of the tree table rows for which the check boxes are selected in the backing bean? Normal iteration to check 'if the check box is true' is not working.
ReplyDeleteHello Andrejus!
ReplyDeleteThanks for a nice post atleast it provided a light in the darkness.
In my project we have to build a tree hiearchy
Root Level-project id
level1- Activity level
level 2- task level
level3 - sub task level
and further if any sub-sub task is there.
It can have n level of hierarchy.I have created 3 sql query based vo's and they are linked internally through join statement. and then i have created 2 view links
i have created 3 transient attribute in all 3 vo's.
But,as per your solutions you have child component in different column. But my results set brings the hierarchy in a single column and I am able to put only 1 single checkbox and bind it to only Parent level transient attribute and not able to use other transient attribute
Please let me know how to implement it for 'n' level hierarchy and checkbox functionality in my case
ReplyDeleteHi Andrejus,
I am on 11.1.2.0.0 version. I tried your application. It works fine. However when i click check box first time it is not checking. It works when we click Check Box second time.
Same thing mentioned by Renan Monteiro's Sharepoint above.
Could you please help on the fix ?
Thanks,
Jit
This will be probably a bug in 11.1.2 version.
ReplyDeleteAndrejus
I need to uncheck the same checkbox when it is checked after some calculation.
ReplyDeleteIs there any way to do that?
Hi Andrejus,
ReplyDeleteI tried the similar approach in JDev 11g PS6 ADF. I am having a tree structure that display 4 levels of information. The checkbox functionality working only for first time. Later debugging the code, I realized that, iterator.hasNext() is returning false from second time. Let me know how to handle this issue. Thanks.
Hi Andrejus,
ReplyDeleteEverything works fine, but this solution is only for two levels treetable.
I've a treetable with unbounded levels, so how can I manage it?
I would like to know if you have a more scalable solution for the checkbox support in ADF treetable.
Thanks a lot.
I guess then you should do the same through hierarchycal View Link. I dont have sample for this.
ReplyDeleteAndrejus
Yes, I've done.
ReplyDeleteBut I don't know how manage it in the bean class