Client sorting and paging not binding correctly

Client sorting and paging not binding correctly

btibti Posts: 7Questions: 2Answers: 0
edited April 2015 in Free community support

Datatables 1.10.5, MVC 5

I don't know how to post a sample or link as it is the server side that is not getting all the data posted correctly.

If I leave default sorting for DT and post page 1, I get all 25 rows returned to the controller. If I change to page 2 and post, I don't get any rows posted to controller. If I change the sort in my code and post from page 1, I don't always get 25 rows posted. When I do a "view page source", all the model binder names and ids look correct for the mvc model binder.

Is there a setting or something I am missing?

Answers

  • AllanCochraneAllanCochrane Posts: 41Questions: 1Answers: 2

    Try setting up a failing test case here http://live.datatables.net/ or use this one as a starting point http://jsfiddle.net/0rqxafhL/4/

    I think you're going to have to give more information if you want help

  • btibti Posts: 7Questions: 2Answers: 0

    I'm trying to set something up but I'm not sure how to replicate what gets posted to the controller for my mvc app

  • btibti Posts: 7Questions: 2Answers: 0

    I have a table with all client side processing. Column 1 has a checkbox, all other columns are text (no inputs). The table has multiple pages and I have paging set at 25 rows and it wrapped in a form tag. I'm doing nothing to the table or sorting, etc - just using default ('#table').datatable(). When submitting the form on page 1, my controller is receiving the 25 rows from page 1 as expected. When changing to page 2 and submitting, my controller is not receiving any rows. If I change sort orders as all, I am also not receiving any rows in my controller.

    In 1 other test I just ran: showing only 25 rows on page 1 and having multiple pages available, a submit only returns 25 rows. When changing row limit to "all" and submitting, I get 1700 rows returned. If I change to page 2 and submit, I get none. Should DT be returning all rows regardless of page size?

  • btibti Posts: 7Questions: 2Answers: 0
    edited April 2015

    I think I have a test case - not failing yet - at least setup.

    http://live.datatables.net/xewahuxa/1/edit?html,js,output

  • btibti Posts: 7Questions: 2Answers: 0

    After further digging and testing in Chrome and looking at post data, it appears as though the submit is only submitting the first page and not the entire table. If I switch to "all", the form does post back all records.

  • btibti Posts: 7Questions: 2Answers: 0

    Making progress. I added the following:

            // make sure to post ALL table records back
            $('#ModifyWaypoints').on('submit', function (e) {
                // Force all the rows back onto the DOM for postback
                table.rows().nodes().page.len(-1).draw(false);  // This is needed
                if ($(this).valid()) {
                    return true;
                }
                e.preventDefault();
            });
    

    This is now posting ALL rows of the table regardless of what page or page size you have selected.

    But, if I search, the reduced set of records are NOT posted. It posts no records.

This discussion has been closed.