Sorting a Date Column when using daterangepicker on the same page

Sorting a Date Column when using daterangepicker on the same page

taylor5042taylor5042 Posts: 21Questions: 6Answers: 0
edited August 2010 in General
I have a table that has a five columns, one of which is a date column.
This is on a page that includes the daterangepicker plugin for selecting start and end dates in a form.
The date column is very slow to sort or even times out with a script error.
If I disable daterangepicker then the date column sorts quickly.
The date format is: YYYY-MM-DD

I am not sure how to fix this, it is like I need to force datatables not to use the daterangepicker for sorting, but how?
Thanks!

Replies

  • taylor5042taylor5042 Posts: 21Questions: 6Answers: 0
    I also have the same problem with date.js
    Any Ideas?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    How does the date range picker interact with DataTables. Does it do filtering on the rows a bit like this: http://datatables.net/examples/plug-ins/range_filtering.html ? If you run the Firebug profiler, what appears to be taking up all the processing time on the page?

    Allan
  • taylor5042taylor5042 Posts: 21Questions: 6Answers: 0
    Allan,
    The date range picker is used to populate a min / max date range in a form.
    When the form is submitted it creates the datatable from the ajaxsource request.
    I can sort on any other column without problems.
    If I disable the daterangepicker plugin and hard code the min and max date fields then the table sorts quickly on the date column.

    profiler shows a lot of functions from daterangepicker which are taking up most of the time.
    The highest being 15% exception()
    [code]
    function (s) {
    var mx = s.match(r);
    if (mx) {
    return [mx[0], s.substring(mx[0].length)];
    } else {
    throw new ($P.Exception)(s);
    }
    }
    [/code]

    The core of this problem seems to be related to date.js which as I understand daterangepicker is built on this.
    If I disable daterangepicker, but include date.js I still have the same problem.
  • taylor5042taylor5042 Posts: 21Questions: 6Answers: 0
    For now I have added a hidden column with the date in unix timestamp format and I am using iDataSort in order to sort the date column.
    This has fixed the compatibility problem.
This discussion has been closed.