Tree Box [message #1014838] |
Tue, 26 February 2013 10:07  |
Eclipse User |
|
|
|
Hi all,
I want use a treebox field of Scout in my project.
I need to load the information from a database and put them into a treebox.
I want use a lookup call parametrized and in the where condition of the query I need to put two date.
Example: Where orderdate between '2013-02-26 00:00' and '2013-02-26 23:59'
someone could help me figure out how to combine treebox with lookup call parameterized.
thanks in advance for the help and explanations
|
|
|
|
|
|
Re: Tree Box [message #1015204 is a reply to message #1015059] |
Wed, 27 February 2013 12:55   |
Eclipse User |
|
|
|
Hi,
Is your data coming from the same table?
Something like:
+-----+-------+-----------+
| id | name | parent_id |
+-----+-------+-----------+
| 125 | Lorem | - |
| 548 | Ipsum | - |
| 587 | Dolor | 125 |
| 874 | Artis | 125 |
+-----+-------+-----------+
For this tree:
+-+ Lorem
| |
| +----- Dolor
| |
| \----- Artis
|
\-- Ipsum
You can use a select like this:
SELECT id, text, NULL, NULL, NULL, NULL, NULL, 1, parent_id, 1
FROM my_table
|
|
|
|
Re: Tree Box [message #1015374 is a reply to message #1015331] |
Thu, 28 February 2013 07:04   |
Eclipse User |
|
|
|
From the wiki page:
http://wiki.eclipse.org/Scout/Concepts/Sql_Lookup_Service#Properties :
Quote:(..) The AbstractSqlLookupService actually allows you to return additional meta-data that controls how the returned data is presented to the users. You can for example return icon IDs, color codes, tooltip texts or font descriptions. The complete list and order of all columns supported by the AbstractSqlLookupService is as follows:
Object key
String text
String iconId
String tooltip
String background color
String foreground color
String font
Boolean enabled (0,1)
Object parentKey used in hierarchical structures to point to the parents primary key
Boolean active (0,1)
The list is also provided by the Javadoc of AbstractSqlLookupService.
A check box in a tree-field, is considered as the value of this field in your form. In other words: the LookupCall/Service is not specific and can be (re)used everywhere (SmartField, SmartColumn, TreeBox, ...).
The usual way is to set the value on the field (dirrectly or using the formdata).
I will try to provide an example.
[Updated on: Thu, 28 February 2013 07:05] by Moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Tree Box [message #1082949 is a reply to message #1014838] |
Fri, 09 August 2013 04:46   |
Eclipse User |
|
|
|
Hi All,
I would like to know if it is possible to use more than one table with the TreeBox with LookupCall?
In my case, I have two tables:
- Product (idProd*, nameProd, cat_idCat)
- Category (idCat*, nameCat)
I create a LookupCall (TreeCategoryLookupCall) to populate the Treebox, the getConfiguredSqlSelect() for the TreeCategoryLookupService is:
@Override
protected String getConfiguredSqlSelect() {
return "SELECT "
+ "p.idProd, "
+ "p.nameProd, "
+ "NULL, "
+ "NULL, "
+ "NULL, "
+ "NULL, "
+ "NULL, "
+ "1, "
+ "c.nameCat, "
+ "1 "
+ "FROM prod p, cat c "
+ "WHERE c.idCat = p.cat_idCat";
}
But all I have is the list of all 'prod' items.
\--prod_item1
|
\--prod_item2
|
\--prod_item3
|
\--prod_item...
I want to have a structure like:
\Cat_item1
| \--prod_item1
| |
| \--prod_item2
|
\Cat_item2
\--prod_item3
|
\--prod_item...
|
|
|
Re: Tree Box [message #1082999 is a reply to message #1082949] |
Fri, 09 August 2013 06:14   |
Eclipse User |
|
|
|
Your example is a very good start.
But you also need to produce LookupRows for "\Cat_item1" and "\Cat_item2".
The LookupService will construct the hierarchy of LookupRows for you if it finds the corresponing rows.
Assuming product Product.idProd and Category.idCat are in separate ranges (e.g. they do not overlap: category ids in range [0, 999] and product ids in range [1000, 9999]), you might be able to do something like this:
(pseudo SQL, I am not sure it is valid):
SELECT
p.idProd,
p.nameProd,
NULL,
NULL,
NULL,
NULL,
NULL,
1,
p.cat_idCat, -- here you provide the id of the parent lookuprow
1
FROM prod p
UNINON
SELECT
c.idCat,
c.nameCat,
NULL,
NULL,
NULL,
NULL,
NULL,
1, -- if you want to disable the "categories lookup rows" put a 0
NULL, -- categories do not have parents.
1
FROM cat c
If the ranges overlap, you need to add something (a prefix like "_cat" -> 'cat_'||p.cat_idCat and 'cat_'||c.cat_id) in order to disambiguate the ids.
I hope it helps.
Related wiki topic: Sql Lookup Service
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.10464 seconds