Home » Eclipse Projects » Eclipse Scout » Tree SmartField Lookup
|
Re: Tree SmartField Lookup [message #1807869 is a reply to message #1807771] |
Tue, 11 June 2019 08:18 |
|
Hi Tim
There's an example for a hierarchical (local) lookup in our widgets application. See the "SmartField with Tree Content" here.
Check out the source code for DefaultTreeSmartField and the HierarchicalLookupCall.java.
When you use the lookup in a SmartField, the field must set the 'browseHierarchy' property, like this:
@Override
protected boolean getConfiguredBrowseHierarchy() {
return true;
}
When you use the AbstractSqlLookupService to create LookupRows, you must select/set the 'parentKey' field on each row. With that information the client builds the hierarchy. The list of rows returned by your LookupService should look like this:
- LookupRow[key=1, text=Root A, parentKey=null]
- LookupRow[key=2, text=A1 (child of A), parentKey=1]
- LookupRow[key=3, text=Root B, parentKey=null]
- LookupRow[key=4, text=B1 (child of B), parentKey=3]
- LookupRow[key=5, text=B1.1 (child of B1), parentKey=4]
- ...
Eclipse Scout Homepage | Documentation | GitHub
|
|
|
Re: Tree SmartField Lookup [message #1809400 is a reply to message #1807869] |
Mon, 15 July 2019 13:45 |
Tim Meuser Messages: 16 Registered: February 2019 |
Junior Member |
|
|
Hi,
thanks for your answer.
I used the tree box sql lookup to build my hierarchy:
@Override
protected String getConfiguredSqlSelect() {
return "" +
"SELECT " +
" C.COMPANY_NR, " + // key
" C.SHORT_NAME || ': ' || C.NAME, " + // text
" C.LOGO, " + // iconId
" C.TOOLTIP, " + // tooltip
" 'F0F0F0', " + // background
" '404040', " + // foreground
" '" + Font.SERIF + "', " + // font: not yet clear how this works
" 1, "+ // enabled
" null, "+ // parent
" 1 "+ // active
"FROM COMPANY C " +
"WHERE 1=1 " +
"AND (C.TYPE_UID = :master OR :master IS NULL) " +
" AND C.COMPANY_NR = :key " +
" AND ((UPPER(C.NAME) LIKE '%'|| UPPER(:text)||'%') OR (UPPER(C.SHORT_NAME) LIKE '%'||UPPER(:text)||'%')) " +
" ";
}
Now my problem is that the tree box is showing nodes with multiple parents correctly, but the smart field is only loading the node one time (images). Is there a way that the smart field looks like the tree box?
|
|
|
Re: Tree SmartField Lookup [message #1809409 is a reply to message #1809400] |
Mon, 15 July 2019 18:16 |
|
Tim Meuser wrote on Mon, 15 July 2019 09:45Now my problem is that the tree box is showing nodes with multiple parents correctly, but the smart field is only loading the node one time (images). Is there a way that the smart field looks like the tree box?
Tim,
That image does not match the SQL you posted, right? Because the SQL seems to select "null" als parent, which would make the list flat...
If the rows are displayed hierarchically, I think all lookup rows are required to have a unique key (so the SmartField can select the current value in the drop down). See the source of HierarchicalLookupResultBuilder.java (the "allRows.contains()" part). So you have to make sure, that the aoi06 below aoi05 is "different" from the aoi06 below aoi04. You could do that by using artifical or compound keys.
Regards,
Beat
|
|
| |
Goto Forum:
Current Time: Wed Sep 25 18:51:41 GMT 2024
Powered by FUDForum. Page generated in 0.03377 seconds
|