Setting aoData dynamically...
Setting aoData dynamically...
luisrortega
Posts: 79Questions: 6Answers: 1
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]
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]
This discussion has been closed.
Replies
[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!
[code]
"sServerMethod": "POST",
[/code]
[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.... :)