0

How to jump between rows???

asked 2012-01-01 20:09:47 +0800

GuzZpaWn gravatar image GuzZpaWn
111 2
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);

} 
}
delete flag offensive retag edit

2 Replies

Sort by ┬╗ oldest newest

answered 2012-01-04 23:57:48 +0800

GuzZpaWn gravatar image GuzZpaWn
111 2

With this code i got jump row from textbox to the next textbox;
but when i get the end of the paging it throw me an exception,
now I'm looking for How to jump paging buttons?

txtPrecio.addEventListener(Events.ON_OK, new EventListener(){
      public void onEvent(Event event) throws Exception {
        ((Listbox)lstm.getParent()).setSelectedIndex(index+1);
        Listitem i=((Listbox)lstm.getParent()).getItemAtIndex(index+1);
        Listcell c=(Listcell) i.getChildren().get(3);
        ((Textbox)c.getValue()).focus();     
      }
    });

link publish delete flag offensive edit

answered 2012-01-10 02:46:10 +0800

paowang gravatar image paowang
140 6

I search the ZK document and I found the css class of paging buttons:
http://books.zkoss.org/wiki/ZK_Style_Guide/XUL_Component_Specification/Paging/Default
maybe we can use JQuery to gain the focus of paging buttons at client side.
for example:

	public void onClick$jump(){
		Clients.evalJavaScript("$('.z-paging-next').get(0).focus();");
	}

I found that the next button doesn't show the focus border, but it really gained the focus. ( press "space" key could trigger this button )
if change the focus to '.z-paging-inp', it will show the focus border correctly.
Hope this helps you.

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-01-01 20:09:47 +0800

Seen: 170 times

Last updated: Jan 10 '12

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