JQuery error
JQuery error
Hi,
I am getting oData is not defined while calling the method "fnStateSave": function (oSettings, oData) to save data to DB.
How can i set the value.
Below is my full code
$(document).ready( function () {
$('table.x2f').append('Group order by(usually hidden)Call Pending NameMobile Res Tel1Res Tel2Res FaxWrk Tel1Wrk Tel2Wrk Fax NationalityCall Status ');
var oTable = $('table.x2f').dataTable({ "bLengthChange": false, "bPaginate": false , "bSearchable": true,
"bStateSave": true,
"fnStateSave": function (oSettings, oData) {
alert("=== oData === "+oData);
//Send an Ajax request to the server with the state object
$.ajax( {
"url": "/state_save",
"data": oData,
"dataType": "json",
"method": "POST",
"success": function () {}
} );
},
"fnStateLoad": function (oSettings, oData) {
alert( 'Saved filter was: '+oData.oSearch.sSearch );
}
})
.rowGrouping({ bExpandableGrouping: true,
iGroupingOrderByColumnIndex: 0,
iGroupingColumnIndex: 1});
var oSettings = oTable.fnSettings();
var oData = oSettings.aaSorting;
$('table th').click( function() {
alert("== inside function === "+oData);
});
});
I am getting oData is not defined while calling the method "fnStateSave": function (oSettings, oData) to save data to DB.
How can i set the value.
Below is my full code
$(document).ready( function () {
$('table.x2f').append('Group order by(usually hidden)Call Pending NameMobile Res Tel1Res Tel2Res FaxWrk Tel1Wrk Tel2Wrk Fax NationalityCall Status ');
var oTable = $('table.x2f').dataTable({ "bLengthChange": false, "bPaginate": false , "bSearchable": true,
"bStateSave": true,
"fnStateSave": function (oSettings, oData) {
alert("=== oData === "+oData);
//Send an Ajax request to the server with the state object
$.ajax( {
"url": "/state_save",
"data": oData,
"dataType": "json",
"method": "POST",
"success": function () {}
} );
},
"fnStateLoad": function (oSettings, oData) {
alert( 'Saved filter was: '+oData.oSearch.sSearch );
}
})
.rowGrouping({ bExpandableGrouping: true,
iGroupingOrderByColumnIndex: 0,
iGroupingColumnIndex: 1});
var oSettings = oTable.fnSettings();
var oData = oSettings.aaSorting;
$('table th').click( function() {
alert("== inside function === "+oData);
});
});
This discussion has been closed.
Replies
Which part is giving your oData undefined - my guess is the fnStateLoad function since it only gets passed one parameter (you need to get the data from the server and give it to DataTables). The documentation for that function is slightly wrong at the moment in that regard, and will be fixed with the next release.
See this post for more information about state saving and loading: http://datatables.net/blog/localStorage_for_state_saving
Allan
Thank you for your support.
I am thinking to pass the sort value to DB and set it to the datatable while page is loading. I am getting the value as 3, ASC, 0 from DB. If I get this vale, please tell me, how Can I set it to dattable to show the order?
I am thinking to pass the sort value to DB and set it to the datatable while page is loading. I am getting the value as 3, ASC, 0 from DB. If I get this vale, please tell me, how Can I set it to dattable to show the order?