Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Tree SmartField Lookup
Tree SmartField Lookup [message #1807771] Sat, 08 June 2019 12:57 Go to next message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
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 08:18 Go to previous messageGo to next message
Andre Wegmueller is currently offline Andre WegmuellerFriend
Messages: 59
Registered: September 2012
Location: Baden-D├Ąttwil, Switzerla...
Member
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 Go to previous messageGo to next message
Tim Meuser is currently offline Tim MeuserFriend
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 Go to previous messageGo to next message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 112
Registered: November 2010
Senior Member
Tim Meuser wrote on Mon, 15 July 2019 09:45
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?


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
Re: Tree SmartField Lookup [message #1809558 is a reply to message #1809409] Thu, 18 July 2019 08:41 Go to previous message
Tim Meuser is currently offline Tim MeuserFriend
Messages: 16
Registered: February 2019
Junior Member
Hi,

yes, this was not the correct SQL Lookup. I added images for my tables and the lookup. I am using a composite primary key for the hierarchy. Maybe you have an additional idea for me, thanks in advance.
  • Attachment: AoiTable.PNG
    (Size: 6.38KB, Downloaded 6 times)
  • Attachment: AreaTable.PNG
    (Size: 5.96KB, Downloaded 5 times)
  • Attachment: Lookup.PNG
    (Size: 12.80KB, Downloaded 8 times)
Previous Topic:drag and drop support
Next Topic:Null Pointer Exception when working with editable tables
Goto Forum:
  


Current Time: Mon Oct 14 03:53:50 GMT 2019

Powered by FUDForum. Page generated in 0.02050 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top