0

Dynamic grid save data

asked 2010-12-28 04:48:26 +0800

gizm0 gravatar image gizm0
33 1

Hello!

In my application I have a grid with a dynamic number of rows and a dynamic number of columns. The cells are editable and I want to keep them in sync with my model to save the data back later.

Here is the code of my grid:

              <grid vflex="1" height="100%">
                <columns height="22px" menupopup="auto"
                  sizable="true">
                  <column forEach="${head}"
                    label="${(empty each) ? c:l('header.default') : each}"
                    sort="auto" />
                </columns>
                <rows>
                  <row forEach="${each.value.properties}">
                    <label value="${each.key}" />
                    <textbox use="translator.ui.ComparableTextbox" apply="translator.controller.EventController"
                      inplace="true"
                      onChange="self.style="font-weight:bold"; tab1.label = "* " + tab1.label;"
                      forEach="${each.value}" value="${each}" />
                  </row>
                </rows>
              </grid>

Thank you in advance for your help.

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2010-12-28 05:40:50 +0800

robertpic71 gravatar image robertpic71
1275 1

First, evaluated expressions (${...) are only 1-way-bindings. For 2-way binding ZK offers annotated databinding (@{xxx}).
But EL's more flexible and it's not possible to create dynamic columns with @databindig. So you have to use EL's and events.

1. Setup a composer (i.e. for the window or another headcomponent)
--> it think apply inside a forEach-loop isn't a good idea....

2. forward the event <textbox forward="onChange=onYourEvent"...
--> note: noChange created interpreted zscript --> good for prototyping, bad for productive environment

3. catch the event (ForwardEvent) inside your javacode

4. retrieve the component from the event (getTarget from the originEvent) --> textbox
4a. and follow the UI tree to get the key or object keys, i.e. getParent() --> row --> getFirstChild() --> key label

or plan B:
create the whole thin in pur java and add eventlistener like swing

/Robert

link publish delete flag offensive edit

answered 2010-12-28 11:01:18 +0800

gizm0 gravatar image gizm0
33 1

Thank you for the fast answer.

I will try it tomorrow.

link publish delete flag offensive edit

answered 2010-12-30 05:13:16 +0800

gizm0 gravatar image gizm0
33 1

I went for Plan A, it worked fine!

Thanks

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-12-28 04:48:26 +0800

Seen: 381 times

Last updated: Dec 30 '10

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