1

Tree and database

asked 2014-02-24 08:51:58 +0800

wijdan gravatar image wijdan
37 5

updated 2014-02-24 12:06:28 +0800

Hi,

i'm using ZK7 with eclipse juno and i'm trying to construct a tree from database data.

I have 2 tables in database: categories & subcategories, the idea is to show all categories in the first level of the tree, then for each category the tree should show its subcategories.

All examples in demo or developper reference are done statically, & i can't find any clear example to implement this.

Can anyone give me a simple example to achieve this, i'ev already retrieved the data from database in a list but i can't find where to put it in the standard methods of the tree component.

Thank you

delete flag offensive retag edit

Comments

do you have an model? (like a class Categorie what has a list of SubCategory)

chillworld ( 2014-02-24 10:52:19 +0800 )edit

yes i have 2 pojos that i use to retrieve data from base, my problem is with the tree class, what should i put in it in order to read the data?

wijdan ( 2014-02-24 12:03:19 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-02-24 12:17:39 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

updated 2014-02-26 06:51:10 +0800

For mvvm : You need to create a new model that extends AbstractTreeModel.

On fiddle is a nice example (with children): http://zkfiddle.org/sample/3dm77ch/1-MVVM-tree

For MVC I found this example on fiddle :

http://zkfiddle.org/sample/3tqq43h/2-Tree-sample

If you look at the zul you will see that you can convert the mvvm to mvc very easy.

If you don't want to write a renderer you can always use an template.
Doc for that : http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVC/View/Template/Tree_Template

Greetz chill.

link publish delete flag offensive edit
1

answered 2014-02-25 22:32:25 +0800

wijdan gravatar image wijdan
37 5

I've managed to make it work with the help of the example you gave.

Thx lot

link publish delete flag offensive edit

Comments

your welcome and again +1 here for your own effort to find it yourself with aid of an example.

chillworld ( 2014-02-26 06:50:14 +0800 )edit
0

answered 2014-02-24 16:32:59 +0800

wijdan gravatar image wijdan
37 5

updated 2014-02-24 16:45:07 +0800

thx for your reply, is there any example with MVC please? If i got it right, in this case, the select of data from the base will be implemented in the method getFooRoot of testVM, right?

link publish delete flag offensive edit

Comments

Yes indeed, but you set the data in the model with the constructor.

chillworld ( 2014-02-24 19:02:03 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2014-02-24 08:51:58 +0800

Seen: 33 times

Last updated: Feb 26 '14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More