fnServerData is not working
fnServerData is not working
i want to implement advance search on a populated table..here is what i have
[code]var oTable = $('#mytable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "server_processing.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
//my code
return nRow;
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "as_strno", "value": $('#strno').val() },
{ "name": "as_temp_ref", "value": $('#as_temp_ref').val() });
aoData.push( { "name": "dateaddedSto", "value": $('#listings_row #dateaddedSto').val() });
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
} );
[/code]
what can be the issue in this code?
[code]var oTable = $('#mytable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "server_processing.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
//my code
return nRow;
},
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "as_strno", "value": $('#strno').val() },
{ "name": "as_temp_ref", "value": $('#as_temp_ref').val() });
aoData.push( { "name": "dateaddedSto", "value": $('#listings_row #dateaddedSto').val() });
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
} );
[/code]
what can be the issue in this code?
This discussion has been closed.
Replies
The push itself looks like it should work. The server_processing.php will need to know how to extract those new parameters, as well. Make sure it's not a PHP issue.
i have a popup window where user can select his parameter to search in datatable...
If that doesn't help, link to a test case.
Allan
i tried this but it is not workin
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "id",
"value": 1 } );
},
where id is the mysql table field in server_processing.php query..simple i wanted to get only that havind id=1
$aColumns = array('is_active','CompanyName', 'email', 'phone_no', 'web_address','id' );
$sIndexColumn = "id";
$sTable = "inf_company";
also set connection to db, Now the jquery function is
"sAjaxSource": "server_processing.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
// Bold the grade for all 'A' grade browsers
if ( aData[0] != 0 )
{
$('td:eq(0)', nRow).html( '' );
}
if ( aData[5] != 0 )
{
// $('td:eq(4)', nRow).html( 'A' ); // You can add your link here!!
$('td:eq(5)', nRow).html( '' );
}
return nRow;
},
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "CompanyName",
"value": "Debenhams" } );
}
Allan
Please this is link
http://pocketcityinfo.com/test/companylist.php
> CompanyName=Debenhams
Looks like it is working to me. Perhaps it is just the server-side script which is not applying the filtering correctly?
Allan
http://pocketcityinfo.com/test/code.txt
If you are just trying to filer on the second column in your table, use fnFilter - if you are adding an additional query, you need to modify the $sWhere variable that is built.
Allan