Tree Box [message #1014838] |
Tue, 26 February 2013 15:07 |
|
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 #1014929 is a reply to message #1014838] |
Tue, 26 February 2013 20:55 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
I have assumed that you know your parameters on the client.
Just add them in a LookupCall (execPrepareLookupCall):
http://wiki.eclipse.org/Scout/Concepts/LookupCall#Members
In my example the parameters are constants set in the client. In the reality I assume they come dynamically from elsewhere.
And use them in the corresponding SqlLookupService:
See the last example for getConfiguredSqlSelect, it used the LanguageLookupCall defined in the first page:
http://wiki.eclipse.org/Scout/Concepts/Sql_Lookup_Service#Properties
---
I can provide more information on the where-clause I added if needed:
WHERE t.from_date < :validityTO AND t.to_date > :validityFROM
---
If the date depends on the current date, I think you can write your select to use trunc(sysdate).
---
NB: Instead of writing the same twice, I haved tried a wiki-first approach. Let me know if this is not enought and I need to fill the gap with more explanations.
[Updated on: Tue, 26 February 2013 21:10] Report message to a moderator
|
|
|
|
Re: Tree Box [message #1015059 is a reply to message #1015017] |
Wed, 27 February 2013 10:30 |
|
Ok, now I can load the root element for each node with a first lookup call, with the method loadRootNode.
Now for each root element, I have to load the child elements. I try to use the same lookup call but it didn't work as hoped because it duplicated the root elements for the number of child elements.
With this sample query I populate the root elements in tree box:
With I change this query in the following way:
Select Root, Child From MyTable
in the tree box, the root elements are duplicated.
For this reason, I would use a second lookup call to retrieve all child elements for each root elements.
Select Child From MyTable Where Root='****'
Is this a correct idea or not? How could I proceed?
[Updated on: Wed, 27 February 2013 10:32] Report message to a moderator
|
|
|
Re: Tree Box [message #1015204 is a reply to message #1015059] |
Wed, 27 February 2013 17:55 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
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 #1015331 is a reply to message #1015204] |
Thu, 28 February 2013 09:25 |
|
Hi Jeremie,
thank you for your help, now I load the tree-box with a similar query that you have posted:
Now my question is: what means all the various null in the query you posted?
Now I would need to set the check box of the node based on a boolean field produced by the query that populates the tree-box, is this possible? How?
-
Attachment: TreeBox.png
(Size: 7.95KB, Downloaded 1052 times)
|
|
|
Re: Tree Box [message #1015374 is a reply to message #1015331] |
Thu, 28 February 2013 12:04 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
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 12:05] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Tree Box [message #1021744 is a reply to message #1014838] |
Wed, 20 March 2013 15:59 |
|
Hi,
I'm here again looking for help.
How can I run a function when the user performs a double-click on an item in the tree-box?
For the moment, I use only a keystrokes, but the final user request that the same function run also on double-click.
Can anyone help me pointing to a possible way?
Thanks in advance for your help
-
Attachment: Immagine.png
(Size: 6.30KB, Downloaded 1065 times)
|
|
|
Re: Tree Box [message #1022134 is a reply to message #1021744] |
Thu, 21 March 2013 10:24 |
Eclipse User |
|
|
|
Ciao Marco
There are two ways to get there:
1: add a listener to the tree in the treebox
@Order(10.0)
public class TestField extends AbstractTreeBox<Long> {
@Override
protected void execInitField() throws ProcessingException {
super.execInitField();
getTree().setCheckable(false);
// solution 01 add a listener
getTree().addTreeListener(new TreeAdapter() {
@Override
public void treeChanged(TreeEvent e) {
if (e.getType() == TreeEvent.TYPE_NODE_ACTION) {
System.out.println("node aciton on '" + e.getNode().getNodeId() + "'");
}
}
});
}
.....
}
2: override the default tree in your treebox:
@Order(10.0)
public class TestField extends AbstractTreeBox<Long> {
....
// solution 02 override the default tree
public class Tree extends DefaultTreeBoxTree {
@Override
protected void execNodeAction(ITreeNode node) throws ProcessingException {
System.out.println("node action");
}
}
}
Hope it helps...
|
|
|
|
Re: Tree Box [message #1028729 is a reply to message #1022281] |
Thu, 28 March 2013 16:59 |
|
Hi all,
I have a new question about tree box. I managed to capture and properly handle the double click on a node, thanks to your help.
Now I want to capture the expanded and collapse event of the node; I tried to add to my listener to handle the event expanded
public void treeExpanded(TreeEvent e)
but without success.
Can you give me a help?
I think that once managed the expanded event correctly, handle the collapse event is similar. Correct?
Thanks in advance for your help
|
|
|
|
Re: Tree Box [message #1082949 is a reply to message #1014838] |
Fri, 09 August 2013 08:46 |
Ranto ANDRIANJAFY Messages: 7 Registered: July 2013 |
Junior Member |
|
|
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 10:14 |
Jeremie Bresson Messages: 1252 Registered: October 2011 |
Senior Member |
|
|
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.06233 seconds