Datatable - Need to display all pagination value for total number of records.

Datatable - Need to display all pagination value for total number of records.

vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

I am using datatable in my project. I have 50,000 records in database tables name is contact.
Using php and ajax i want to show this in my web page.
when page load i am showing 10 records only.
My problem is i want to display all pagination links. currently only 1 link is display for pagination for 10 records.
i need 1 2 3 4 5 6.........and more for all the records 50,000.

Is there any hardcoded setting we can do for total records and using this hardcoded value pagination will display automatically for all records.

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 9,791Questions: 0Answers: 1,620

    This example should help - it's showing alternative paging. If it doesn't, look at other options with option pagingType, or you can create your own paging plugin,

    Colin

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    pagingType and example did not work.
    I am trying with pagin plugin.

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    plugin also not working

  • kthorngrenkthorngren Posts: 10,585Questions: 25Answers: 2,409

    Please provide a link to your page or a test case showing the issues so we can help.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    I am using php and ajax for showing records from database to datatable.

    I have 50,000 records in database.

    if we show 50,000 records at a time then it is taking too much time.
    so what i did, i am fetching only 10 records from database and showing into datatable.

    Now First Scenario:
    -> if we show 50,000 records at a time, then all pagination links at the bottom will display.
    Like: 1 2 3 4 5 6 7 8 9 10........5000

    Second Scenario:
    -> If we show only 10 records at a time the pagination show only 1 link
    Lik: 1

    What I want:
    when page will load 10 records will display(same as scenario 2)
    But i need pagination same as Scenario 1:
    Like: 1 2 3 4 5 6 7 8 9 10 ......5000

    Is it possible ?

    Can you please give me your email id so i can share the files.

  • kthorngrenkthorngren Posts: 10,585Questions: 25Answers: 2,409
    edited October 18

    Sorry I wasn't understanding your question. Server Side Processing mode is used for server side paging. Here are some examples. The protocol has builtin parameters for fetching the total records and will display the paging and information fields correctly. The ssp.class.php is used in the examples and can be used by you if you wish.

    Kevin

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    ssp.class.php worked for me. Thanks you so much :smile:

    But below problem is there:

    in ssp.class.php i am using complex() function and in this when we pass where parameter me getting below error:
    column CON_TY.field_213 not found.

    my code is:
    $filter_val_html = 'Product Quality';
    //$supplier_id = $REQUEST['supplier_id'];
    $filter_val_query = ucwords(str_replace('
    ', ' ', $filter_val_html));

    $whereResult="";
    if($filter_val_html != "all_contacts")
    $whereResult = " CON_TY.field_213 = '$filter_val_query'";

    $where_query = '';
    echo json_encode(
    SSP::complex( $_GET, $sql_details, $table, $primaryKey, $columns , $whereResult, $where_query)
    );

    Also how to pass variable value from view page to server.php page.

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0
    edited October 19

    I have used my own custom query inside complex function.

    My query is join query, which join four tables in the database.

    After adding custom query inside complex function, search functionality also not working. It is giving me error "Invalid Json"

    Can you please help me into this ?

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    I have added my custom select query inside complex function.

  • allanallan Posts: 52,631Questions: 1Answers: 8,052 Site admin

    That sounds like the right why to handle it. The SSP class is really only meant to be a basic functional demo. For more complex use cases, including simple joins, you need to modify the script.

    Allan

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    ok....Thank you so much for your support.

  • vishalkalbandevishalkalbande Posts: 9Questions: 1Answers: 0

    Hi Allan,

    Now i am facing one small issue with same. Requesting to you please guide me.

    I am using ssp.class.php file.

    Scenario 1:

    --> I have 10,000 records in database.

    --> When i am using select * from customer table query, pagination looks like below:

    --> 1 2 3 4 5 6 7 8....1000

    --> This scenario is correct.

    Scenario 2 (This is problem)

    --> I have 10,000 records in database.

    --> when i am using select * from customer where salary > $50, which returns 20 records from database. pagination looks like below:

    --> 1 2 3 4 5 6 7 8....1000 which is wrong.

    it should be -> 1 2

    Solution which i am trying:

    "recordsTotal" => intval( $recordsTotal ),
    "recordsFiltered" => intval( $recordsFiltered ),

    If i give hardcode value for $recordsFiltered 20 then pagination looks good for second scenario.

    but if i store value 20 in variable and pass this variable to here "recordsFiltered" => intval( $recordsFiltered ), when page load pagination look good but when i click second link pagination which 2 then pagination disappear.

    Can you please guide me, how to solve this issue.

    I need only 2 pagination links for 20 records.

  • colincolin Posts: 9,791Questions: 0Answers: 1,620
    Answer ✓

    '''
    --> when i am using select * from customer where salary > $50, which returns 20 records from database. pagination looks like below:

    --> 1 2 3 4 5 6 7 8....1000 which is wrong.

    it should be -> 1 2
    '''

    Have you confirmed the query is only returning the expected data?

    If so, can you post the JSON returned from that script here, please,

    Colin

Sign In or Register to comment.