-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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; }
this my layout
Asked: 2013-08-03 07:37:49 +0800
Seen: 29 times
Last updated: Apr 10 '14