jsp - How to search a date range with dandelion datatables -
i developing web app using dandelion datatables server side processing, pagination , filtering. version using 1.1.0 (jsp)
i want use external form update dataset of datatable. table has 2 fields: start date, stop date below:
<datatables:table id="mytableid" url="/results" serverside="true" serverparams="getfilterparams" processing="true" theme="bootstrap3" cssclass="table table-striped"> <datatables:column title="start date" property="startdate" filterable="false" /> <datatables:column title="stop date" property="stopdate" filterable="false" /> </datatables:table>
in external form using bootstrap datetimepicker
<sf:form id="searchform"> <div class="form-group"> <div>start date</div> <div class='input-group date' id='startdate'> <input name='startdate' type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <div class="form-group"> <div>stop date</div> <div class='input-group date' id='stopdate'> <input name='stopdate' type='text' class="form-control" /> <span class="input-group-addon"> <span class="glyphicon glyphicon-calendar"></span> </span> </div> </div> <div> <button id="searchbtn" class="btn btn-primary btn-search searchbutton" type="button" onclick="otable_mytableid.ajax.reload();">search</button> </div> </sf:form>
javascript
function getfilterparams(aodata) { aodata.push({"name" : "startdate", "value" : $('#startdate').val()}); aodata.push({"name" : "stopdate", "value" : $('#stopdate').val()}); }
controller
@requestmapping(value = "/results") public @responsebody datatablesresponse<results> findallfordatatables(httpservletrequest request) { datatablescriterias datatablecriterias = datatablescriterias.getfromrequest(request); (columndef columndef : datatablecriterias.getcolumndefs()) { switch (columndef.getname()) { case "startdate": columndef.setsearch(request.getparameter("startdate")); break; case "stopdate": columndef.setsearch(request.getparameter("stopdate")); break; } } dataset<results> results = this.resultsserviceimpl.findresultswithdatatablescriterias(datatablecriterias); return datatablesresponse.build(results, datatablecriterias); }
could please give me direction on filter results searching rows within range selected in datetimepicker external form
thanks
recently did same kind of task , solved particular issue following technique:
- i created model class datefrom , dateto fields.
- when user selects dates in datepickers , presses "confirm" button server receives post request @modelattribute containing datefrom , dateto.
- then retrieve data database dates (e.g.
select * table (date between :datefrom , :dateto)
) , send view.
Comments
Post a Comment