0

Dynamic grid creation

asked 2010-02-09 08:33:38 +0800

maurix gravatar image maurix
9 1 1 1

I'm usign ZK 5.0 and i want to build a grid with dynamic columns and dynamic data. I have a pojo called Page, this has a List<PageRow> fmember and every PageRow has a List<PageField> fields member. I have a zul page with a grid and in his controller class i set the model in this way:
Page page = mycode...return...

ListModelList model = new ListModelList(page.getPageRows());
mygrid.setModel(model);

in zul page i have:
<grid id="mygrid">

<rows>
<row self="@{each=item}" value="@{item}">
<custom-attributes campi="@{item.fields}" composite="list"/>
<label value="@{each}" forEach="@{campi}" ></label>
</row>
</rows>

But i have a resulting grid with all the rows but only a column with no value inside. Where i'm wrong?
It's possible draw this grid with zul page mixin with java code in controller, or i must create the grid programmatically only in java code??

delete flag offensive retag edit

35 Replies

Sort by ยป oldest newest

answered 2011-06-18 11:19:35 +0800

eduk79 gravatar image eduk79
9

Hi as1225, could you give me some advice on this grid question: I need to create a grid to display objects that have the following attributes (String typeOfExpense, Date payDate, Integer amount, String Details).
The grid should have a first column TypeOfExpense (string) and then as many columns (dates) as the user defines in two variables (startDate and endDate). Then each row would have a first element typeOfExpense combobox and then the following row elements would be the objects specified above. So, the object's amount attribute should displayed in the intersection of typeOfExpense and date. Additionally, the user should be able to add new rows to the grid to create new expense objects. That is, pressing an add button the user should be able to create a new row and select the typeOfExpense from the combo in the first element of the row and then select a cell from certain column (which have a date between start and end). This cell should be auto-wired to some textbox, datebox, intbox and textbox so that the user can input values and then have the amount displayed on the grid after pressing a save button.

Too messy? Hope I have been clear enough, but the idea is having a grid that dynamically creates the number of columns needed according to the date values start and end, and then presenting the expense objects where the type of expense and date match the object's values. The additional difficulty is that the user must be able to add new rows and have the cells wired to some components to input the new values of the expense object.

I'll leave a small sketch:



TypeOfExpense Jan-11 Feb-11 Mar-11 Apr-11 ....


Electricity 1000 1300 1500 2000 ....


Gas 100 200 300 250 ....

TypeOfExpense: Gas
PayDate: Apr/24/11
Amount: 250
Details: Some detail of the expense


Many thanks,
eduk79

link publish delete flag offensive edit

answered 2011-06-18 13:10:38 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Hi eduk79, please post your question as a NEW thread.

link publish delete flag offensive edit

answered 2012-02-28 04:30:09 +0800

Prabakaran gravatar image Prabakaran
9

Hi everyone,

I had a problem to load tree nodes dynamically. Following is my requirement,

[-] continents
Asia
Africa
North & South America
Europe
Australia

While i click the "Asia", their Countries will be added to Asia as a child node. While click the child country node, their Cities will be added to Country as a child node.

Please help,

Thanks in advance

link publish delete flag offensive edit

answered 2012-03-02 03:11:45 +0800

jimmyshiau gravatar image jimmyshiau
4921 5
http://www.zkoss.org/ ZK Team

Hi Prabakaran,
You can use TreeModel.

link publish delete flag offensive edit

answered 2012-11-15 06:56:32 +0800

azgard gravatar image azgard
37 3

Hello, I tried the example with the code that jimmyshiau suggested
MyComposer.java
index.zul
items.zul
columns.zul,
but that example just complete the first column with data (ITEM1, ITEM.....) , I am trying to complete all the table with data but I got problems.
My objective is complete the table with a query each time that a press a button, I could with appendChild but without I have the problem that " jimmyshiau " mention:

"because the grid will redraw again when the row call appendChild
we use Executions.createComponents("items.zul", row, params) and forEach
it will prepare a zul page and just need to attach one time"

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2010-02-09 08:33:38 +0800

Seen: 10,702 times

Last updated: Nov 15 '12

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