-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hai All,
Please provide a simple example how to filter a data in GRID/CHART based on DATE.
Hi,
<listbox mold="paging" sizedByContent="true" height="500px"
span="true" autopaging="true" pagingPosition="bottom"
model="@load(vm.lstChiamate)" selectedItem="@bind(vm.selected)"
onSelect="@command('abilitaDelete')">
<auxhead sclass="category-center">
<auxheader>
<image src="/images/search.png" />
<textbox id="filtroRagSoc" instant="true" width="50%"
onChange="@command('applicaFiltro')" />
<image src="/images/search.png" />
<datebox id="filtroDataVis" instant="true" width="80%"
locale="it_IT" mold="rounded" lenient="true" format="dd/MM/yyyy"
onChange="@command('applicaFiltro')" />
This simple listbox show some record. OnChange I fire a command: applicaFiltro
@Command
@NotifyChange("lstChiamate")
public void applicaFiltro()
{
ElencoChiamateClienti ut = new ElencoChiamateClienti();
ut.setRagione_sociale(filtroRagSoc.getText());
ut.setLogin_inserimento(filtroLogin.getText());
ut.setCliente(filtroCli.intValue());
SimpleDateFormat dfIn = new SimpleDateFormat("dd/MM/yyyy");
java.util.Date DataTransito=null;
Boolean ok=true;
if(ok && filtroDataVis.getValue() != null)
{
try
{
DataTransito=dfIn.parse(filtroDataVis.getText());
Calendar c = Calendar.getInstance();
c.setTime(DataTransito);
c.set(Calendar.HOUR, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
Timestamp ts = new Timestamp(c.getTimeInMillis());
ts.setNanos(0);
ut.setData_visita(ts);
} catch (WrongValueException e)
{
ok=false;
logger.error("Programma:"+gTitoloVideata+" Funzione:applicaFiltro " +"Errore:"+ e.getMessage());
uv.apriMessagebox(gTitoloVideata, "Errore in applicaFiltro. \n"+e.getMessage(), win);
} catch (ParseException e)
{
ok=false;
logger.error("Programma:"+gTitoloVideata+" Funzione:applicaFiltro " +"Errore:"+ e.getMessage());
uv.apriMessagebox(gTitoloVideata, "Errore in applicaFiltro. \n"+e.getMessage(), win);
}
catch (java.lang.NullPointerException e)
{
; // semplicemente non � stato compilato il campo e quindi non mi interessa
}
}
ChiamateClientiDAO pdao = (ChiamateClientiDAO)SpringUtil.getBean("ChiamateClientiDAO");
lstChiamate=pdao.findElencoVisite(ut);
BindUtils.postNotifyChange(null,null,Adm_elenco_visite.this,"lstChiamate");
selected=null;
}
The fields was bounded with @wire....
@Wire("#filtroRagSoc")
Textbox filtroRagSoc;
@Wire("#filtroCli")
Intbox filtroCli;
@Wire("#filtroDataVis")
Datebox filtroDataVis;
This was executed in afterCompose....
@AfterCompose
public void afterCompose(@ContextParam(ContextType.VIEW) Component view)
{
Selectors.wireComponents(view, this, false);
}
In DAO I search the record
public List<ElencoChiamateClienti> findElencoVisite(ElencoChiamateClienti ec) throws org.springframework.dao.DataAccessException
{
Format fmt = new SimpleDateFormat("yyyy-MM-dd");
List<ElencoChiamateClienti> list=null;
String sql ="select chc.progressivo,chc.cliente,cli.ragione_sociale,chc.data_chiamata,chc.esito_acquisto, "+
"chc.esito_contatto,chc.data_visita,chc.agente,chc.chiamata_chiusa,chc.login_inserimento "+
"from tp_chiamate_clienti chc, tg_clienti cli "+
"where cli.progressivo = chc.cliente "+
" and chc.esito_contatto ='V' "+
" and chc.esito_acquisto ='X' "+
" and cli.ragione_sociale like '"+ec.getRagione_sociale()+"%' "+
" and chc.login_inserimento like '"+ec.getLogin_inserimento()+"%' ";
if(ec.getData_visita() != null)
sql = sql + " and chc.data_visita between '"+ec.getData_visita()+"' and '"+fmt.format(ec.getData_visita())+" 23:59:59' ";
if(ec.getCliente() > 0)
sql = sql + " and cli.progressivo = "+Integer.toString(ec.getCliente());
sql = sql + " order by data_visita, ragione_sociale";
That should be all that is needed. Luca
p.s. But this is a matter which should be considered a little presentation of the problem....
Asked: 2015-05-12 05:56:41 +0800
Seen: 23 times
Last updated: May 17 '15
ZK 7.0.3 doAfterCompose is not called for GenericForwardComposer
Power of ZK Calender With Charts 2 and Other Components
ZK7 atlantic theme: vlayout/hlayout spacing
Structuring zul-code without includes?
css zk 7.0.3 with ie9 not work
Change listbox MVVM template with Java or how to let user change column order