Filtering and sorting not working

Filtering and sorting not working

stefutz101stefutz101 Posts: 5Questions: 1Answers: 0
edited May 2018 in Free community support

Hello, I'm new into data tables, and if I try to order a column ascendent or descendent the data is reloaded but in reloaded in the same order. Same with search and filters. If I apply a filter the entire data is reloaded.

JS FILE

, columns:[ {
                field:"title", title:"title", width:90, template:function(t) {
                    return t.title
                }
            } ]
  • a column exemple
, sortable:!0, pagination:!0, search: {
                input: $("#generalSearch"), delay: 400
            }
  • search input
$("#m_form_status").on("change", function() {
            t.search($(this).val(), "title")
        }
  • filter

PS: are just parts from the file, if it´s unclear i can post the entire script.

<select class="form-control m-bootstrap-select m-bootstrap-select--solid" id="m_form_status">
                                                                <option></option>
                                                                <option value="0">FALSE</option>
                                                                <option value="1">TRUE</option>
                                                            </select> 
  • select element from .php file
    I mention that it worked on demo data.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @stefutz101 ,

    Those code snippets are too small to make sense of, I'm afraid. If you could link to your page, or create a fiddle, that would be the most useful.

    Cheers,

    Colin

  • stefutz101stefutz101 Posts: 5Questions: 1Answers: 0
    edited May 2018

    Hi @colin,
    Thanks for your answer.
    https://jsfiddle.net/bbdoosh5/
    Here´s the fiddle, it hope it helps.

    { "meta": { "page": 1, "pages": 1, "perpage": -1, "total": 6, "sort": "asc", "field": "id" }, "data": [ { "id": "1", "title": "Product title", "keyword": "keyword", "price": "1316", "category": "3", "photo_path": "products\/FB_FS_A1033.jpg", "video_rev": "20", "photo_rev": "20", "text_rev": "20", "no_rev": "30", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-15", "begin_data": "2018-05-17", "end_data": "0000-00-00", "owner": "123@yahoo.com", "note": "Lorem ipsum dolor sit amet, nonummy ligula volutpat hac integer nonummy. Suspendisse ultricies, congue etiam tellus, erat libero, nulla eleifend, mauris pellentesque. Suspendisse integer praesent vel, integer gravida mauris, fringilla vehicula lacinia non", "paid": "1" }, { "id": "2", "title": "product title", "keyword": "testt", "price": "12323", "category": "4", "photo_path": "products\/FB_FS_A0150.jpg", "video_rev": "7", "photo_rev": "14", "text_rev": "14", "no_rev": "12", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-20", "begin_data": "2018-05-09", "end_data": "0000-00-00", "owner": "123@yahoo.com", "note": "salut", "paid": "0" }, { "id": "3", "title": "product title", "keyword": "testt", "price": "12323", "category": "4", "photo_path": "products\/FB_FS_A0150.jpg", "video_rev": "7", "photo_rev": "14", "text_rev": "14", "no_rev": "12", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-20", "begin_data": "2018-05-09", "end_data": "0000-00-00", "owner": "123@yahoo.com", "note": "salut", "paid": "0" }, { "id": "4", "title": "test", "keyword": "123", "price": "13.37", "category": "4", "photo_path": "products\/FB_FS_A0400.jpg", "video_rev": "5", "photo_rev": "9", "text_rev": "10", "no_rev": "16", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-20", "begin_data": "2018-05-18", "end_data": "0000-00-00", "owner": "123@yahoo.com", "note": "salut", "paid": "0" }, { "id": "5", "title": "test title", "keyword": "keyword123123", "price": "123.99", "category": "3", "photo_path": "products\/FB_FS_A1073.jpg", "video_rev": "3", "photo_rev": "8", "text_rev": "10", "no_rev": "19", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-20", "begin_data": "2018-05-10", "end_data": "2018-06-14", "owner": "123@yahoo.com", "note": "salut", "paid": "0" }, { "id": "6", "title": "testttt", "keyword": "123123", "price": "19.99", "category": "4", "photo_path": "products\/FB_FS_A0111.jpg", "video_rev": "5", "photo_rev": "9", "text_rev": "14", "no_rev": "15", "cvideo_rev": "0", "cphoto_rev": "0", "ctext_rev": "0", "cno_rev": "0", "added_data": "2018-05-20", "begin_data": "2018-05-02", "end_data": "2018-06-06", "owner": "123@yahoo.com", "note": "123123", "paid": "0" } ] }´
    

    callback.php

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    DataTables expects a HTML table for its data. You don't seem to have one.

  • stefutz101stefutz101 Posts: 5Questions: 1Answers: 0

    The loading part is working. The script is loading data into "#column_rendering".

            <!--begin: Datatable -->
                                    <div class="m_datatable" id="column_rendering"></div>
                                    <!--end: Datatable -->
                                </div>
    

    My problem is that sorting and filters are not working:

    Same with price and search input.

    Sorting:

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    The table isn't shown in your JSFiddle. Can you link to a page that demonstrates the issue please?

    Your JSFiddle also uses:

    $(".m_datatable").mDatatable( {
    

    Are you using a library other than DataTables, or perhaps a wrapper to DataTables? DataTables doesn't provide a mDatatable jQuery method.

    As I say, we'd need a working test case that demonstrates the issue to be able to help.

    Allan

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Looking a bit further into it, mDatatable appears to be provided by the Metronic 5 theme. You'd need to contact their support about that - that's nothing to do with the library presented here.

    Allan

This discussion has been closed.