0

Prevent the columns prices to zero when line added

asked 2012-08-08 05:56:20 +0800

onsir gravatar image onsir
132 2

updated 2012-08-08 05:57:16 +0800

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();
        }
    }


example
first I took the data and add a line, for example I only take 3 data only, in the value column of the price still 0.0
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


thanks

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2012-08-09 01:19:55 +0800

onsir gravatar image onsir
132 2

Is there another way ?

link publish delete flag offensive edit

answered 2012-08-09 04:14:09 +0800

onsir gravatar image onsir
132 2

updated 2012-08-09 04:14:47 +0800

this my picture
http://img96.imageshack.us/img96/3297/nonzero.gif

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: 2012-08-08 05:56:20 +0800

Seen: 80 times

Last updated: Aug 09 '12

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