ServerProcessing and local ajax search using DataTables 1.10

ServerProcessing and local ajax search using DataTables 1.10

wnkunguwnkungu Posts: 2Questions: 1Answers: 0

Hi,

I am having an issue making both serverside with parameters and the ajax search box work. I have my datatables initialized like this

   var table = $('#recommendations_table');

    table.DataTable({
        "processing": true,
        "serverSide": true,
        "sAjaxSource": "scripts/recommendations_processing.php",
        "fnServerParams": function (aoData) {                
            aoData.push({ "name": "cid", "value": $('#committee_one').val() });
            aoData.push({ "name": "mid", "value": $('#ministry_one').val() });
            aoData.push({ "name": "sid", "value": $('#sector_one').val() });
        }
      });

With that I have the table and the server parameters working but the ajax search box is not filtering my search queries. I had tested the same code above with ajax parameter instead of sAjaxSource and without the fnServerParams, that test had both the table and the search box working ok. So I'm left to wonder how do you pass server parameters in the new datatables and have all the features working including the search box filtering.

Thanks

Answers

  • wnkunguwnkungu Posts: 2Questions: 1Answers: 0

    I think I got it working after digging into the docs:

            "processing": true,
            "serverSide": true,
            "ajax": {
                "url": "scripts/recommendations_processing.php",
                "data": function (d){
                    d.cid = $('#committee_one').val();
                    d.mid = $('#ministry_one').val();
                    d.sid = $('#sector_one').val();                    
                }
            },
    
This discussion has been closed.