Event after an Ajax call is completed
Event after an Ajax call is completed
cmtsampaio
Posts: 3Questions: 0Answers: 0
Hi there,
Maybe this is a very noobish question but I'm sorry.. I gotta present it or I'll go crazy!
$(document).ready(function() {
$("#USERS").dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 5,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": gurl_tbl_users,
"oLanguage": {
"sSearch": "Search Ticket:"
}
});
}
First off all, this implementation makes the datatable access the ajaxcall URL, retrieving and showing quite nicelly my data.
My question is, how do I register an event or funcion (or listen to one already implemented) so I can, by instance alert() the number of rows retrieved from the server?
I saw this one:
$(document).ready( function() {
$('#USERS').dataTable( {
"fnDrawCallback": function( oSettings ) {
alert( 'DataTables has redrawn the table' );
}
} );
} );
but I think there is some initialization issues about it... an alert() pops up...
Thanks in advance for any help given!
Maybe this is a very noobish question but I'm sorry.. I gotta present it or I'll go crazy!
$(document).ready(function() {
$("#USERS").dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 5,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": gurl_tbl_users,
"oLanguage": {
"sSearch": "Search Ticket:"
}
});
}
First off all, this implementation makes the datatable access the ajaxcall URL, retrieving and showing quite nicelly my data.
My question is, how do I register an event or funcion (or listen to one already implemented) so I can, by instance alert() the number of rows retrieved from the server?
I saw this one:
$(document).ready( function() {
$('#USERS').dataTable( {
"fnDrawCallback": function( oSettings ) {
alert( 'DataTables has redrawn the table' );
}
} );
} );
but I think there is some initialization issues about it... an alert() pops up...
Thanks in advance for any help given!
This discussion has been closed.
Replies
"DataTables warning (table id = 'game_sessions'): Cannot reinitialise DataTable.
To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy"
Allan
working...
1 - what is the best way to get the total number of rows?
2 - And how do I customize the number of rows to show in the listbox (it's fixes to 10/25/50/1000),, I searched and found those values on the DataTables javascript file implementation...
edited:
Ok my first question was not that hard (LOL)
//Init. Game Sessions table
gs_tbl = $("#USERS").dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"iDisplayLength": 20,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": gurl_tbl_gs,
"bFilter": false,
"fnDrawCallback": function() {
alert( gs_tbl.fnSettings().fnRecordsTotal() );
}
});
for the second question I added:
"aLengthMenu": [10,20,30,40],
nice!
PS! Thanks for the answer Allan! :)
Currently with this plug-in: http://datatables.net/plug-ins/api#fnPagingInfo . v1.10 will have something similar built in.
> 2 - And how do I customize the number of rows to show in the listbox (it's fixes to 10/25/50/1000)
As you say - aLengthMenu :-)
Allan