Monday, 16 September 2013

ADF - Tree Table Column Drop Down

ADF - Tree Table Column Drop Down

To use Drop Down Lists in ADF Tree Tables. There are a few things to keep in mind.

Assumptions: I am using the HR schema, and I'm going to be working with the Employees table. You have already created the Attributes LOV (List Of Values)

Firstly when using the drop down list, the #{node.ManagerId} is not correct.

Remember to make sure all your attributes that you want to work with are in the Bindings of the table.

When using the drop down list, there are two components you need namely:
af:selectOneChoice: is the Actual Selected Item
f:selectItems: is the List Of Values

Also keep in mind, all your Sub Levels within the Table, might not have that same Columns as the parent, and thus it will Display an error when this happens.

To make a editabledrop down List, you need to have a submit Button on the page, and make the af:selectOneChoice, autoSubmit="true".

Lets get to the Code.
<af:selectOneChoice required="#{node.bindings.ManagerId.hints.mandatory}"
 rendered="#{node.ManagerId == null ? false : true}"
  <f:selectItems value="#{node.bindings.ManagerId.items}"
A Quick Explination rendered="#{node.ManagerId == null ? false : true}"  Basically checks to see if the row has something, otherwise it does not display the Drop Down Box.

Note: This does not work if your Item initially is null, but you want to display it, I will be updating this on how to do it.
Update: You could try something like
#{node.bindings.ManagerId == null or node.bindings.ManagerId.estimatedRowCount > 0 ? false : true}
in the rendered Property

Good Luck