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:

  1. i created model class datefrom , dateto fields.
  2. when user selects dates in datepickers , presses "confirm" button server receives post request @modelattribute containing datefrom , dateto.
  3. then retrieve data database dates (e.g. select * table (date between :datefrom , :dateto)) , send view.

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -