0

Add rows manually in Live Data grid

asked 2008-12-18 10:01:23 +0800

evpole gravatar image evpole
481 2

there's a grid in a goods-order page,in which the custormers could type goodsname in it to form a order.
I've bind all other data to datamanager.and also, I want to bind the goods data to datamanager.I did like this:

------------------------------------------------
<grid model="@{goodslist}" id="goodsgrid">
<columns>

<column label="goods name" />
<column label="color" />
<column label="num" />

</columns>
<rows id="rows">
<row self="@{each='goods'}">
<combobox autodrop="true" value="@{goods.name }" />
<combobox value="@{goods.color }" />
<intbox />
</row>
</rows>
</grid>

--------------------------------------------
but there's a problem: when page load, the goodslist is empty, and no rows is displayed to the user.
I tryed to add a blank row like this which will work if I didn't band it to datamanager:

-----------------------------------------
void addnew(){
Row nrow=new Row();

nrow.setParent(rows);
new Label("new row").setParent(nrow);
new Textbox().setParent(nrow);


}

-------------------
but it pops error: "index 0,size 0"

and then, I tryed to add a blank row like this:

------------------------
void add(){
TreeSet gl=new TreeSet();
shen.Goods goods = new shen.Goods();
goods.setName("NAME");
goods.setCname("color");
gl.add(goods);

bill.setGoodslist(gl);
}
---------------------------
the new row didn't appear too.

Could anyone please tell me the way to add rows to a livedata grid ?

delete flag offensive retag edit

8 Replies

Sort by ยป oldest newest

answered 2008-12-18 10:14:13 +0800

iantsai gravatar image iantsai
2755 1

Maybe you should make your data set well prepared before ZK page rendered.

Can you tell why you can't do this?

link publish delete flag offensive edit

answered 2008-12-19 01:31:51 +0800

evpole gravatar image evpole
481 2

thanks for your response!

This grid is used to receive the goods information which is posted by the customers other than to get information from server.
in other words, it sends information to the server,other than the normal usage (get information from server).

so I can't prepare data before.

link publish delete flag offensive edit

answered 2008-12-19 04:18:18 +0800

evpole gravatar image evpole
481 2

I've found a way to do it:
I could not band it to the datamanager,and I can manually operate the JavaBean in zscript to update the goodslist when user submit the page.
but I have to loop the all the rows manually.

is there any better way to do it ?

link publish delete flag offensive edit

answered 2008-12-26 11:37:41 +0800

PeterKuo gravatar image PeterKuo
481 2

A better way to replace "loop the all the rows manually"?
You may do it "incrementally"? Only update newly added goods to the rows?

link publish delete flag offensive edit

answered 2008-12-27 01:40:31 +0800

evpole gravatar image evpole
481 2

updated 2008-12-27 01:41:09 +0800

Thanks for your response!

I whish to find a way to use model in this situation.so I could not loop the rows manually to save it,all the goods information was set to the javabean which was used as a model.

is it possible to use model and add rows in the grid ?

link publish delete flag offensive edit

answered 2008-12-27 16:41:24 +0800

robertpic71 gravatar image robertpic71
1275 1

Have you seen my examples? I use listbox, but it's the same for grid-models. Get the inner (GUI) Model and add your new bean twice: 1x UI-model, 1x real model.

Another way is to get binder and load the component (of course, this would be a full reload form the grid).

/Robert

link publish delete flag offensive edit

answered 2008-12-28 03:39:47 +0800

evpole gravatar image evpole
481 2

haha,very very good example !
Thank you very much ,dear robert !

link publish delete flag offensive edit

answered 2009-01-05 02:12:12 +0800

evpole gravatar image evpole
481 2

Hi, robert.
I've studied your example a few days,and got understood at last.
and here, I would like to share some thing with you:

I've found that I need to add my bean only once.
beacause the model is bind to the real bean, so when change the modellist,the real bean is changed automatically.
I guess the reason is as follow:
in my application,I got the modebean from page attribute, instead of get it from PearsonDao.getInstance();

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: 2008-12-18 10:01:23 +0800

Seen: 1,126 times

Last updated: Jan 05 '09

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