-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How can I make the value of the price column to be non-zero when the Add line in listbox ?
I have added a row to process data in the listbox, listbox column 2 i.e code item and price. for goods code I took the data from the database and displayed in the listbox with the column price still 0.0. later in this column in the input prices would cost value.
When I input the value in the price already columns in rows 1,2,3 price. then I add the new line, but why the value in the column Price to be 0.0 also
UnitPrice.zul
<?xml version="1.0" encoding="UTF-8"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" root="./winUnitPrice" ?> <?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <listbox id="listUnitPrice" multiple="true" rows="10" checkmark="true" mold="paging" pageSize="20" > <listhead> <listheader label="ItemCode" ></listheader> <listheader label="Price" ></listheader> </listhead> <listitem self="@{each='Item'}" value="@{Item}"> <listcell label="@{Item.itemCode}"></listcell> <listcell><doublebox id="dblPrice" constraint="no negative" width="90%" ></doublebox> </listitem> </listbox> <div> <button id="addRow" label="Add" forward="onClick=onBtnClickAddRow(evt)" ></button> </div>
public class UnitPriceController extends GenericForwardComposer { private Item item; private Doublebox dblPrice; private Listbox listUnitPrice; private ListModelList listModelUnitPrice = new ListModelList(); @Override public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); // TODO Auto-generated method stub dblPrice.setValue(0.0); } //method for add row in list box public void onBtnClickAddRow(Event evt) { try { List<Item> listItem=new ArrayList<Item>(); listItem=(List)event.getData(); for(Item items : listItem){ item=new Item(); item.setItemCode(items.getItemCode()); listModelUnitPrice.add(item); listUnitPrice.setModel(listModelUnitPrice); } } }); } catch (Exception ex) { ex.printStackTrace(); } }
row item price 1 B001 0.0 2 B002 0.0 3 B003 0.0 then i input value price, like this row item price 1 B001 1,000 2 B002 2,000 3 B003 3,000 then I would like to add more lines with 1 data, but the value in the price column so 0.0 all After add row row item price 1 B001 0.0 2 B002 0.0 3 B003 0.0 4 B004 0.0 -->new add row
this my picture
http://img96.imageshack.us/img96/3297/nonzero.gif
Asked: 2012-08-08 05:56:20 +0800
Seen: 80 times
Last updated: Aug 09 '12