0

How to fill in a value in a particular row column in a listbox

asked 2013-08-03 07:37:49 +0800

onsir gravatar image onsir
132 2

updated 2013-08-03 07:48:38 +0800

How to fill in a value in a particular row column in a listbox My examples the input of value in a textbox in listbox on the line 1 column 1 ( items code ), then i press tab When the textbox lostfocus then it will search the data to a database based on the code in the item type, and the result of this search will be displayed/fill values in row 1 column 2 (description), and the active cursor on row 1 column 3 (Qty) column 3 whichever is Intbox thanks

this my code .zul

<listbox id="listboxPacking" multiple="true" rows="5" 
         nonselectableTags=" " 
     mold="paging" pageSize="5" height="160px" sizedByContent="true"
         model="@{win$composer.emptyRow}">                                    
 <listhead>
 <listheader label="Row"        width="50px" />
 <listheader label="Item code"  width="110px"/>
 <listheader label="Description" />
     <listheader label="Qty Pack" width="60px"/>
 </listhead>
<listitem self="@{each='Item'}" value="@{Item}">
    <listcell label="@{Item.row}"/>
    <listcell>
            <textbox id="txtItemCode" value="@{Item.itemCode}"  cols="8"/>
            <button id="btnShowFindItem" label=".."/>
        </listcell>
    <listcell label="@{Item.description}"/>  
        <listcell ><intbox id="QtyPack" value="@{Item.qtyPack}"/></listcell>
    </listitem>

</listbox>

in java class

public class PackController extends GenericForwardComposer {

@Autowired ItemService itemService;

private Textbox txtItemCode;

@Override
public void doAfterCompose(Component comp) throws Exception {
    super.doAfterCompose(comp);


    comp.getFellow("txtItemCode").addEventListener("onChange", new EventListener() {
    @Override
    public void onEvent(Event event) throws Exception {

        int rowIndex=listboxPacking.getSelectedIndex();           
        String itemCode=readListboxOnChange(listboxPacking,String.valueOf(rowIndex));

         //find data Item
         item=new ProductItem();  
         item=itemService.getByCode(itemCode);


        //hOw to set value item.getDescription()
        //in listbox in rowActive and column 3  ?


    }});

}

public String readListboxOnChange(Listbox listboxPacking,String rowIndex){ String itemCode=null; String valueRow=null; try{ for (Object item : listboxPacking.getItems()) { if (item instanceof Listitem) { Listitem lstItem = (Listitem) item; for (Object cell : ((Listitem) lstItem).getChildren()) { if (cell instanceof Listcell) { Listcell listcell = (Listcell) cell; if (((Listcell) cell).getListheader() != null) {

                            if (((Listcell) cell).getListheader().getColumnIndex()==1) {
                                 valueRow=(((Listcell) cell).getLabel());
                             }
                             for (Object innercell : listcell.getChildren()) {
                       if (innercell instanceof Textbox ){
                                        if (((Listcell) cell).getListheader().getColumnIndex()==2) {
                                            valueItemCode=((Textbox)innercell).getValue();
                                           }
                                    }
                              } 

                      }
                  }
              }

           }

           if(valueRow.equalsIgnoreCase(rowIndex)){
              itemCode=valueItemCode.trim();
              break;
           }

       }

}catch(Exception e){
      e.printStackTrace();
}

return itemCode; }

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2014-04-10 05:57:16 +0800

onsir gravatar image onsir
132 2

updated 2014-04-10 05:57:48 +0800

this my layout

image description

link publish delete flag offensive edit
Your answer
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
1 follower

RSS

Stats

Asked: 2013-08-03 07:37:49 +0800

Seen: 29 times

Last updated: Apr 10 '14

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