Moving info (#_info) content elsewhere

Moving info (#_info) content elsewhere

stetheyidstetheyid Posts: 8Questions: 0Answers: 0
edited November 2010 in General
I'd like to be able to place the content (e.g. Showing 1 to 25 of 398 entries (filtered from 1,632 total entries)) into an existing element on my page.

I've tried several methods for this but can;t find one that displays the correct information (as seen in the #crmData_info div in the footer - my table is called crmData) when content is first loaded and any filtering/pagination takes place.

Table setup as follows:

[code]
objTable = $('#crmData').dataTable( {
"aoColumns": [
{ "sWidth": "5%", "sClass": "alignCenter", "sType": "string" },
{ "sWidth": "0%", "bSortable": false, "bVisible": false },
{ "sWidth": "10%" },
{ "sWidth": "55%" },
{ "sWidth": "20%"},
{ "sWidth": "10%", "sClass": "alignCenter", "sType": "string" }
],
"aaSorting": [[3,'asc']],
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bPaginate": true,
"bFilter": true,
"bSort": true,
"bAutoWidth": false,
"bInfo": true,
"bProcessing": true,
"iDisplayLength": 25,
"sAjaxSource": "my_ajax_file_that_prints_json.php",
"sDom": '<"H"rplfT>t<"F"ip>',
"bStateSave": true,
"fnServerData": function ( sSource, aoData, fnCallback ) {
var aoData = new Array();
var iArchive = (document.getElementById("chkArchive").checked==true) ? 1 : 0;

aoData.push( { "name": "allocatedUser", "value": $('#cmbAllocatedUser').val() } );
aoData.push( { "name": "recordType", "value": $('#cmbRecordType').val() } );
aoData.push( { "name": "industryType", "value": $('#cmbIndustry').val() } );
aoData.push( { "name": "includeArchive", "value": iArchive } );
$.getJSON( sSource, aoData, function (json) {
fnCallback(json)
} );
}
});
[/code]

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'd suggest adding an fnDrawCallback method ( http://datatables.net/usage/callbacks#fnDrawCallback ) to copy the text in the info element to where ever you want it to go.

    Allan
  • stetheyidstetheyid Posts: 8Questions: 0Answers: 0
    Thanks Allan - I did try that.
    This is what happens:

    on first draw I get in my element: Showing 0 to 0 of 0 entries
    whilst in the _info element is: Showing 1 to 10 of 3,561 entries

    Then, upon clicking next (pagination) I get....

    in my element: Showing 1 to 10 of 3,561 entries
    in the _info element: Showing 11 to 20 of 3,561 entries

    It always seems to be one step behind
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Ah okay - I wonder if the fnDrawCallback is actually being called before the info options then (it's in an array of callbacks which is just looped through - I'll investigate as that sounds like an issue...). However for the time being, fnInfoCallback offers an alternative ( http://datatables.net/usage/callbacks#fnInfoCallback ). It will give you the string which is about to be inserted, so you can stick that into the element you want.

    Allan
  • stetheyidstetheyid Posts: 8Questions: 0Answers: 0
    edited November 2010
    Thanks!
This discussion has been closed.