Server side processing with Next and Previous buttons

Server side processing with Next and Previous buttons

Problem:
This is my DataTable and I would want to have Next - Previous buttons instead of numbers. Is there a way to customize the buttons in DataTable for server side processing.

Replies

  • mansidixit1805@gmail.commansidixit1805@gmail.com Posts: 4Questions: 0Answers: 0
    edited February 2023
                            jQuery(function () {
                                jQuery("#metricId").
                               on('xhr.dt', function ( e, settings, json, xhr ) {
                               \$('#sortValue').val(json.sortValue)
                                        } )
                               .dataTable({
                                    // automatically set DataTables options based on number of records and pageSize
                                   "serverSide": true,
                                   "ajax": {
                                       "url": contextPath + "/metrics/getchartDataRows",
                                       "data": function ( d ) {
                                           d.search_after = \$('#sortValue').val();
                                           d.chartConfigId = \$('#chartConfigId').val();
                                       }
                                   }           
                                })
                            })
    

    Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Yes, use the pagingType option. Set it to be simple.

    Allan

  • mansidixit1805@gmail.commansidixit1805@gmail.com Posts: 4Questions: 0Answers: 0

    pagingType option gives me 'Next' and 'Previous' but these buttons are not actionable meaning nothing happens on-clicking the buttons. How can I trigger ajax call for next page using these buttons similar to what we do with the numbered paging.

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Seems to work okay here: https://live.datatables.net/qoliyehi/2/edit .

    Perhaps you can link to a page showing the issue?

    Allan

  • mansidixit1805@gmail.commansidixit1805@gmail.com Posts: 4Questions: 0Answers: 0

    yeah...my response was missing resultFiltered, hence it didn't work.
    Working fine now after adding the paramater.

    Thanks Allan for support !!!

Sign In or Register to comment.