Tree SmartField Lookup [message #1807771] |
Sat, 08 June 2019 08:57  |
Eclipse User |
|
|
|
Hi,
I am currently trying to expand the scout beginner tutorial by adding a sub_organization_id that references the organization_id, so that a organization can have multiple sub organzations. Now I would like to modify the SmartField in the PersonForm to show the organization tree structure. I looked at the scout widget page, but I didn't find a implementation with sql lookup. Do I need to change the organization sql lookup call? Is there something else I need to change?
|
|
|
Re: Tree SmartField Lookup [message #1807869 is a reply to message #1807771] |
Tue, 11 June 2019 04:18   |
Eclipse User |
|
|
|
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]
- ...
|
|
|
Re: Tree SmartField Lookup [message #1809400 is a reply to message #1807869] |
Mon, 15 July 2019 09:45   |
Eclipse User |
|
|
|
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?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24517 seconds