-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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 ?
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.
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 ?
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 ?
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
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();
Asked: 2008-12-18 10:01:23 +0800
Seen: 1,126 times
Last updated: Jan 05 '09