Filter a date column by range using a datepicker

Filter a date column by range using a datepicker

AntonioLGAntonioLG Posts: 2Questions: 0Answers: 0
edited July 2010 in General
Hi!

I'm trying to filter a column by a range date using two input fields. The examples I've seen use the keyup event this way:

[code]
$('#min').keyup(function () { oTable.fnDraw(); });
$('#max').keyup(function () { oTable.fnDraw(); });
[/code]

I'm trying to use a datepicker (the jquery UI one) to let the user choose the date from it, so I used the change() event, as the user won't press any key to select the date:

[code]
$('#min').change(function () { oTable.fnDraw(); });
$('#max').change(function () { oTable.fnDraw(); });
[/code]

I've tested that the change event is captured, but it doesn't launch the function declared in:

[code]$.fn.dataTableExt.afnFiltering.push(....);[/code]

I think it's because it's only executed with the keyup event, but I'm not sure. Any ideas?
Thanks

Replies

  • EmekaEmeka Posts: 13Questions: 0Answers: 0
    edited July 2010
    Are you using serverside data ajax/json?

    If so, I did something similar using:
    [code]
    aoData.push( { "name": "min", "value": $('#min').val() } );
    aoData.push( { "name": "max", "value": $('#max').val() } );[/code]

    and

    [code]
    $('#min').change( function () { oTable.fnFilter( $(this).val(), 0 );} );
    $('#max').change( function () { oTable.fnFilter( $(this).val(), 0 );} );[/code]

    have a look at my post, last entry works a treat...
    http://datatables.net/forums/comments.php?DiscussionID=2103&page=1#Item_6
  • AntonioLGAntonioLG Posts: 2Questions: 0Answers: 0
    No, I'm getting the data directly from the DOM. I had already read your post, but I think that approach wouldn't work with DOM datasource.
This discussion has been closed.