Setting aoData dynamically...

Setting aoData dynamically...

luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
edited January 2014 in DataTables 1.9
Hi,

I'm looking to establish a small search engine where the result displays on a dataTable. I added a button to the toolbar to call that function to create a custom ajax, once I have it, I intent to apply it to the datatable... it seems to accept it, however it's not displaying it...

I also though about dynamically change the sAjaxSource, but could not find the property...

Any direction is welcome :)

[code]
"aButtons": [
{"sExtends": "text",
"sButtonText":"Refresh", "sButtonClass": "my_button_space_class",
"fnClick": function ( nButton, oConfig, oFlash ) {
DoSearch();
}
},
...


function DoSearch(){
// create url filters from user selected options
var MyCustomURL = "Data.php?tbl=7";
$.ajax({url: MyCustomURL, success:function(result){
HomeSearchT.dataTable().data( result.aaData);
//HomeSearchT.fnSettings().aoData = result.aaData;
//alert(result);
}});

}


[/code]

Replies

  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    Ok, I think I figure it out... (still need to change the php side)

    [code]

    // do not set the sAjaxSource thru initialization... that way it does not try to fill with ALLLL data :)
    // set it during the refresh button click...
    "fnClick": function ( nButton, oConfig, oFlash ) {
    HomeSearchT.fnSettings().sAjaxSource = "Data.php?tbl=7&";
    HomeSearchT.fnReloadAjax(null, null, true);

    //DoSearch();
    }

    // make sure you setup the proper parameters before data is requested...
    "fnServerParams": function ( aoData ) {
    aoData.push({
    "ItemID": document.getElementById("HomeSearchItemID").value ,
    "Title": document.getElementById("HomeSearchTitle").value
    }
    )

    [/code]

    Now, all I have to do is to setup the proper filters on the php side, based on passed parameters... I'll try that one tomorrow... (its 12:45 am here) good nite!
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    Ok, I worked a bit more with it... I'm not receiving nothing on the POST... When I debug it on the browser, I can see the values (document.getElementById("HomeSearchItemID").value ), however on the php side I'm not receiving it....
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    be aware that I also set the server method to post... still nothing on server side...

    [code]
    "sServerMethod": "POST",
    [/code]
  • luisrortegaluisrortega Posts: 79Questions: 6Answers: 1
    dddaaaahhhhh

    [code]
    "fnServerParams": function ( aoData ) {
    aoData.push(
    {
    "name": "ItemID",
    "value": document.getElementById("HomeSearchItemID").value
    },
    {
    "name": "Title",
    "value": document.getElementById("HomeSearchTitle").value
    }
    )

    [/code]

    now it's working.... :)
This discussion has been closed.