Search/Show entries and pagination not working correctly

Search/Show entries and pagination not working correctly

mattmillenmattmillen Posts: 10Questions: 0Answers: 0
edited November 2013 in DataTables 1.9
Hi There,

I think this is a great plugin by the way. I have nearly done everything i wanted to with it however i have a few outstanding issues if you could help please.

http://www.cfolending.net/securelogin/
username: temp
password: 8C3TUdav

the search filter and show number of entries just wont go on one line and does when data is calling local data and not from the database? any ideas why? Am i missing something? as the pagination does not work correctly either.

Also i need to add the search date range function. how do i do this? would this just be a query for that date?

I have marked up here the issues.
http://www.cfolending.net/leadsexample.jpg

Debug code here: aheyik

This is also an example of how it should look with local data pulled in. just so you can see i have had it working
http://www.cfolending.net/example

Thanks in advance if you can help as im nearly there!

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Hi!

    Good to hear that you are nearly there with your DataTables integration! I've just tried the page, but I'm getting a login error with the credentials from above I'm afraid.

    Regarding the alignment of the search and filter input - this is probably a CSS issue, that I'll be able to help you with when I can access the page. I'll try it again in a little while.

    Regarding the date range filtering - since you are using server-side processing, you'll need to send the dates to the server, so the script can take these into account in the processing of the data and calculating what the client-side should show. To do that, you would use fnServerParams:

    [code]
    fnServerParams: function ( d ) {
    d.push( { "name": "startDate", "value": $('#startDate').val() } );
    d.push( { "name": "endDate", "value": $('#endDate').val() } );
    }
    [/code]

    (updating the parameter names as required of course!). That will send the PHP script which you can then access using `$_REQUEST['stateDate']` etc, and append as WHERE conditions to the SQL that the script generates.

    Finally regarding the paging - your server-side script is only returning 1 row at the moment, so it might well actually be working, but since there is only one row, the paging controls are disabled. It doesn't look quite correct in its styling - is that the problem you are looking at rather than actually going to the next page?

    Regards,
    Allan
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    sorry the login details should be:

    username: matt.millen@intentideas.com
    password: 6TFEeNK5ejg526d
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    Regarding the pagination if you look at this example http://www.cfolending.net/example/

    then login and look you will see what i mean
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Re: Pagination - I'm afraid I must be missing something. The pagination on the /example/ table appears to work as I'd expect. It shows the buttons first, previous, 1, 2, 3, 4, 5, next, last, navigating through the 6 pages in the table as required. What does it show / do when you try it? Also, what browser are you using?

    I think something has gone wrong int he plugin.css file. It has:

    [code]
    .dataTables_length, .dataTables_filter{padding: 15px;left
    float: left;}
    [/code]

    I think you want:

    [code]
    .dataTables_length,
    .dataTables_filter{
    padding: 15px;
    }
    .dataTables_length {
    float: left;
    }
    [/code]

    Regards,
    Allan
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    Sorry Allan, miss-communication on my part. That's the one that is working fine.

    Please see this one.
    http://www.cfolending.net/securelogin/

    username: matt.millen@intentideas.com
    password: 6TFEeNK5ejg526d

    This was an example of it working fine.
    http://www.cfolending.net/example/
    this example call the data locally where as the one above calls via database. please see http://www.cfolending.net/securelogin/
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Ah, sorry for the misunderstanding!

    I've just tried the paging not he securelogin/ page and it actually appears to work okay for me. It doesn't show the page numbers as the sPaginationType hasn't been set (it was `sPaginationType: 'full_numbers'` in the other example).

    Also, I notice in the server-side processing return there is:

    > "iTotalRecords":"15","iTotalDisplayRecords":"15"

    These should be integers rather than string values. It doesn't look like what is causing the problem, but it won't help much either :-).

    Regards,
    Allan
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    Ok i added the script and not i get this:

    DataTables warning (table id = 'datatable'): Cannot reinitialise DataTable.

    To retrieve the DataTables object for this table, pass no arguments or see the docs for bRetrieve and bDestroy


    Also when you mention "iTotalRecords":"15","iTotalDisplayRecords":"15" not being integer where would i change this value?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    You'd add the `sPaginationType` option into where you currently initialise the DataTable, rather than in a separate script. i.e. in the inline script where you have:

    [code]
    $(document).ready(function() {
    $("#datatable").dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "table.php"
    } );
    } );
    [/code]

    currently.

    Regarding the integers: It would be in your server-side script (table.php) the assignment of those two parameters could just be wrapped in `intval()` - i.e. `"iTotalRecords" => intval( $totalRecords )` - or however your script is made up!

    Regards,
    Allan
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    Great thanks for this. I made the changes you recommended, however do data shows now?

    Any ideas why
    Please see this one.
    http://www.cfolending.net/securelogin/

    username: matt.millen@intentideas.com
    password: 6TFEeNK5ejg526d

    I created a debug for you also: exafud
  • mattmillenmattmillen Posts: 10Questions: 0Answers: 0
    Ok i think i know the issue, just don't know how to solve it.

    if i add this it breaks and not data shows:


    $(document).ready(function() {
    $("#datatable").dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "table.php"
    "sPaginationType": "full_numbers"
    } );
    } );



    if i i remove "sPaginationType": "full_numbers"


    $(document).ready(function() {
    $("#datatable").dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "table.php"
    } );
    } );



    it is then ok again however pagination still does not work? Where am i going wrong?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    The first one in the code above doesn't work as there is no comma after the sAjaxSource line - thus it is invalid Javascript. It should read:

    [code]
    $(document).ready(function() {
    $("#datatable").dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": "table.php",
    "sPaginationType": "full_numbers"
    } );
    } );
    [/code]

    Regards,
    Allan
This discussion has been closed.