Problem in datatables server side callback on onchange event of select box
Problem in datatables server side callback on onchange event of select box
Hi,
I am facing an isssue with datatable callback.
I want to send the values of year and month on onchange event of my month select box to my ajaxsource so that i get the data according to the year and month. Can Anyone suggest what should i do for this?
firstly i do this
jQuery(document).ready(function() {
var oTable=jQuery('#past_emails').dataTable( {
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"sServerMethod": "POST",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php echo SITE_URL; ?>business/show_email_history/",
'fnServerData': function(sSource, aoData, fnCallback)
{
aoData.push( { "name": "Year", "value": "2012" } );
aoData.push( { "name": "Month", "value": "05" } );
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
"fnDrawCallback": function( oSettings ) {
alert( 'DataTables has redrawn the table' );
}
} );
it is working perfect but when i select year and month then on onchange event of month these values will post to the function "show_email_history" and then according to year and month my table will be reloaded with the new data. for this I tried-
$('#sel_month').change(function(){
var selected_year=$('#sel_year option:selected').val();
var selected_month=$('#sel_month option:selected').val();
var oSettings=oTable.fnSettings();
var sSource="<?php echo SITE_URL; ?>business/show_email_history/";
oSettings.fnServerData(sSource, aoData, fnCallback)
{
aoData.push( { "name": "Year", "value": selected_year } );
aoData.push( { "name": "Month", "value": selected_month } );
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
console.log(oSettings);
oTable.fnDraw();
});
but it is not working. please help me for this.
and many more things but still not getting any solution
I am facing an isssue with datatable callback.
I want to send the values of year and month on onchange event of my month select box to my ajaxsource so that i get the data according to the year and month. Can Anyone suggest what should i do for this?
firstly i do this
jQuery(document).ready(function() {
var oTable=jQuery('#past_emails').dataTable( {
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"sServerMethod": "POST",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php echo SITE_URL; ?>business/show_email_history/",
'fnServerData': function(sSource, aoData, fnCallback)
{
aoData.push( { "name": "Year", "value": "2012" } );
aoData.push( { "name": "Month", "value": "05" } );
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
},
"fnDrawCallback": function( oSettings ) {
alert( 'DataTables has redrawn the table' );
}
} );
it is working perfect but when i select year and month then on onchange event of month these values will post to the function "show_email_history" and then according to year and month my table will be reloaded with the new data. for this I tried-
$('#sel_month').change(function(){
var selected_year=$('#sel_year option:selected').val();
var selected_month=$('#sel_month option:selected').val();
var oSettings=oTable.fnSettings();
var sSource="<?php echo SITE_URL; ?>business/show_email_history/";
oSettings.fnServerData(sSource, aoData, fnCallback)
{
aoData.push( { "name": "Year", "value": selected_year } );
aoData.push( { "name": "Month", "value": selected_month } );
$.ajax
({
'dataType': 'json',
'type' : 'POST',
'url' : sSource,
'data' : aoData,
'success' : fnCallback
});
}
console.log(oSettings);
oTable.fnDraw();
});
but it is not working. please help me for this.
and many more things but still not getting any solution
This discussion has been closed.