Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

How can I use use an external Form to search for data inside a Date Range

$
0
0

I have multiple Datatables that inside a tabbed view, which are built on the fly based on some json data.

I have an external form with filtering data that is populated in the initComplete event and thenbound to my Submit click event which allows me to search on those fields. The below code works fine but now the last piece of the puzzle is to also allow a Date Range search, this is proving difficult. if I use my existing code and simply search for whats in my DatePicker t works, but I cannot figure out how to Search for a range of dates between a start and end date using the same method.

               $("#table-" + tabid).DataTable({
                 //etc..
                initComplete: function () {
                    var column1 = this.api().column(1); //Cities Column
                    var column6 = this.api().column(6); //Cause Column
                    var column8 = this.api().column(8); //Start Date Column


                    //External Search form receive Submit Event
                    $('#submit-' + tabid).click(function () {
                        var c = $('#city-' + tabid).val();
                        var s = $('#style-' + tabid).val();
                        column1.search(c).draw()
                        column6.search(s).draw()

                        // Date range filter
                        var StartDate = $('#from' + tabid).val();
                        var EndDate= $('#to' + tabid).val();

                        column8.search(s).draw()  <----How to do a Date Range Search here.

                    });

Viewing all articles
Browse latest Browse all 2364

Trending Articles