-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I have this:
<combobox id="FiltroContadores" hflex="true" model="@load(vm.movimientos)" itemRenderer="@load(vm.rendererFiltroContadores)"/>
When model changes, itemRenderer is not called and combobox empties.
How can I re-render its items?
I tried calling ListDataEvent when model changes but I don't know if the code is wrong becuase items are not rerendered (I have a System.out.println in the renderer and it is not called):
new ListDataEvent(FiltroContadores.getModel(), ListDataEvent.CONTENTS_CHANGED, -1, -1);
new ListDataEvent(FiltroEquipos.getModel(), ListDataEvent.CONTENTS_CHANGED, -1, -1);
new ListDataEvent(FiltroInstalaciones.getModel(), ListDataEvent.CONTENTS_CHANGED, -1, -1);
Thank you
EDIT: This is the code where I get the list "movimientos"
@GlobalCommand("obtenerMovimientosConsulta")
@NotifyChange("movimientos")
public void obtenerMovimientosConsulta(){
String fromYear = "";
String fromMonth = "";
String fromDay = "";
String toYear = "";
String toMonth = "";
String toDay = "";
fromYear = funciones.Field(fechasCriteriosSeleccion.getDBDesde().getText(), "/", 3);
fromMonth = funciones.Field(fechasCriteriosSeleccion.getDBDesde().getText(), "/", 2);
fromDay = funciones.Field(fechasCriteriosSeleccion.getDBDesde().getText(), "/", 1);
toYear = funciones.Field(fechasCriteriosSeleccion.getDBHasta().getText(), "/", 3);
toMonth = funciones.Field(fechasCriteriosSeleccion.getDBHasta().getText(), "/", 2);
toDay = funciones.Field(fechasCriteriosSeleccion.getDBHasta().getText(), "/", 1);
listaMovimientos = instalacionDAO.findMovimientos(codigosInstalaciones, fromYear, fromMonth, fromDay, toYear, toMonth, toDay);
}
And this is the renderer:
class AvoidingDuplicateRenderer implements ComboitemRenderer<Object> {
private String _type;
private List<String> _rendered = new ArrayList<String>();
@Override
public void render(Comboitem item, Object data, int index)throws Exception {
Movimiento m = (Movimiento)data;
String label = "";
if("contador".equals(_type)){
label = m.getNombreContador();
}else if("equipo".equals(_type)){
label = m.getNombreEquipo();
}else if("instalacion".equals(_type)){
label = m.getNombreInstalacion();
}
if (_rendered.contains(label)) {
item.setParent(null);
item.detach();
} else {
item.setLabel(label);
_rendered.add(label);
}
System.out.println("renderer");
}
public void setType (String type) {
_type = type;
}
}
Here are two examples for how combobox work... zk-combobox-with-item-rendered
May be this will help you to get answer.
Asked: 2013-07-05 09:35:46 +0800
Seen: 104 times
Last updated: Jul 08 '13
How you wrote the code can you share your viewmodel
sjoshi ( 2013-07-05 10:49:38 +0800 )edit@shoshi, I edited the question to add some data. As you can see I have a System.out.println inside the renderer. And when model change it is not called.
Neus ( 2013-07-05 11:14:02 +0800 )editWhen model going to change is you Notify your model List
sjoshi ( 2013-07-05 14:19:24 +0800 )editWhy are you using MVVM and renderers?
davout ( 2013-07-05 15:55:20 +0800 )editI don't know hot to do the same I'm doing in the renderer with MVVM
Neus ( 2013-07-08 08:06:50 +0800 )edit