-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I want to do the following: click me pressing INTRO and when i get txtPrecio and press INTRO it must jump to the next row and this way till the end.
This is the code: (any suggestion) I'm using ZK 5.0.9 CE
<window id="win" title="Cotización" width="100%" height="100%"
apply="pbz.ctrl.tran.cotiz.CotizacionWINCtrl">
<listbox id="listbox" width="100%" height="450px" mold="paging" pageSize="10" pagingPosition="top">
<listhead>
<listheader label="Producto" width="100%"></listheader>
<listheader label="Unidad" width="100px"></listheader>
<listheader label="Cantidad" width="70px"></listheader>
<listheader label="Precio" width="60px"></listheader>
<listheader label="SubTotal" width="100px"></listheader>
</listhead>
<listfoot>
<listfooter><label value=""></label></listfooter>
<listfooter><label value=""></label></listfooter>
<listfooter><label value=""></label></listfooter>
<listfooter><label value="Total"></label></listfooter>
<listfooter><label id="lblTotal"></label></listfooter>
</listfoot>
</listbox>
</window>
public class ListCotizacionRender implements ListitemRenderer {
public void render(Listitem lstm, Object o) throws Exception {
final cotizaciondetaVO x=(cotizaciondetaVO)o;
final Textbox txtCantidad=new Textbox("0.0");
final Textbox txtPrecio=new Textbox("0.0");
final Label lblSubTotal=new Label("0.0");
txtCantidad.addEventListener(Events.ON_OK, new EventListener(){
public void onEvent(Event event) throws Exception {
txtPrecio.focus();
}
});
txtCantidad.addEventListener(Events.ON_FOCUS, new EventListener(){
public void onEvent(Event event) throws Exception {
txtCantidad.select();
}
});
txtPrecio.addEventListener(Events.ON_FOCUS, new EventListener(){
public void onEvent(Event event) throws Exception {
txtPrecio.focus();
}
});
txtCantidad.addEventListener(Events.ON_CHANGE, new EventListener(){
public void onEvent(Event event) throws Exception {
Double cantidad=0.0;
Double precio=0.0;
Double subtotal=0.0;
if(Util.isDouble(txtCantidad.getValue()))
cantidad=Double.parseDouble(txtCantidad.getValue());
else
txtCantidad.setValue("0.0");
if(Util.isDouble(txtPrecio.getValue()))
precio=Double.parseDouble(txtPrecio.getValue());
else
txtPrecio.setValue("0.0");
subtotal=cantidad*precio;
lblSubTotal.setValue(subtotal.toString());
x.setCantidad(BigDecimal.valueOf(cantidad));
x.setPrecio(BigDecimal.valueOf(precio));
x.setSubtotal(BigDecimal.valueOf(subtotal));
}
});
txtPrecio.addEventListener(Events.ON_CHANGE, new EventListener(){
public void onEvent(Event event) throws Exception {
Double cantidad=0.0;
Double precio=0.0;
Double subtotal=0.0;
if(Util.isDouble(txtCantidad.getValue()))
cantidad=Double.parseDouble(txtCantidad.getValue());
else
txtCantidad.setValue("0.0");
if(Util.isDouble(txtPrecio.getValue()))
precio=Double.parseDouble(txtPrecio.getValue());
else
txtPrecio.setValue("0.0");
subtotal=cantidad*precio;
lblSubTotal.setValue(subtotal.toString());
x.setCantidad(BigDecimal.valueOf(cantidad));
x.setPrecio(BigDecimal.valueOf(precio));
x.setSubtotal(BigDecimal.valueOf(subtotal));
}
});
Listcell cell = new Listcell(x.getProducto());
cell.setParent(lstm);
cell=new Listcell(x.getUnidad());
cell.setParent(lstm);
cell = new Listcell();
cell.appendChild(txtCantidad);
cell.setParent(lstm);
cell = new Listcell();
cell.appendChild(txtPrecio);
cell.setParent(lstm);
cell=new Listcell();
cell.appendChild(lblSubTotal);
cell.setParent(lstm);
}
}
Hi, I guess your requirement is when a user clicks "ENTER" key in a Textbox, the cursor change to next row's Textbox, right? I think you can use
//inside Textbox's onOK event handler
Event.getTarget()
to get the textbox in a row and use relative path to navigate to next row's textbox (i.e., textbox.getParent().getNextSibling() ) and call focus().
The requirement is similar to a previous post.
Asked: 2012-01-01 19:16:16 +0800
Seen: 130 times
Last updated: Jan 23 '13