Retrieving only the rows for a selected day
Retrieving only the rows for a selected day
ChrisKolli
Posts: 28Questions: 8Answers: 0
in Editor
Hey guys so i have a big table in my database that i only want todays rows to be retrieved.
I got a datepicker working and the selection works too, but only if I reload the page,
Basically i dont know how to reload the table after selecting a date.
This is my ajax call that works when i reload the page:
var table = $('#calendar').DataTable( {
dom: 'Brtf',
ajax: {
url: 'php/table.calendar.php',
type: 'POST',
data: {
'Date' : $('#submittedDate').val(),
}
},
columnDefs:[
{...},
],
order: [],
columns: [
{...}
The "where" condition in my php:
->where( 'date', $_REQUEST['Date'])
and the js of the datepicker:
$(document).ready(function() {
$(".datepicker").datepicker({
altField : '#submittedDate',
altFormat : 'yy-mm-dd',
dateFormat : 'dd.mm.yy',
showOn: "button",
showAnim: 'slideDown',
showButtonPanel: true ,
autoSize: true,
buttonImage: "//jqueryui.com/resources/demos/datepicker/images/calendar.gif",
buttonImageOnly: true,
buttonText: "Select date",
closeText: "Clear"
});
$('#displayedDate').on('click', function () {
$('#calendar').DataTable().ajax.reload();
});
});
So what do i hve to do to reload the table?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Try using
ajax.data
as a function otherwise it will only use the value of$('#submittedDate').val()
found at initialization.Kevin
I'm a bit confused, what do you mean?
like this?
Take a look at the
ajax.data
examples. Do something like this:Kevin
got it to work
used your code and fixed mine I had a mistake in my reload function. works like this now