Scroller incorrect behavior

Scroller incorrect behavior

Werner_ItenWerner_Iten Posts: 3Questions: 1Answers: 0
edited November 2016 in Scroller

Hello.

I have decided to use Scroller for table.
Faced with incorrect length value.

Here is an example - https://jsfiddle.net/nickita/2ucxpoem/.

As you can see I set total records to 33 but it loads 54 records from start because of incorrect length value.

My question is: how length is calculated and how to fix the issue?

Thank you.

Answers

  • allanallan Posts: 63,230Questions: 1Answers: 10,417 Site admin

    I would suggest that this is wrong:

    ien=data.start+data.length

    It should really check to see if that value is greater than the number of records available (33) and if so, just limit the loop to 33.

    The length parameter is the page size that DataTables is expecting to display, so even in this case, it is correct an expected that length should be submitted as larger than start + number of records on last page.

    Allan

  • Werner_ItenWerner_Iten Posts: 3Questions: 1Answers: 0

    Length value is equal to 54 from start. That is why there are 54 rows in table. But I am not sure why start length is 54.

  • Werner_ItenWerner_Iten Posts: 3Questions: 1Answers: 0

    I also have issue in my project.

    I have 33 rows in database. I have initialized Scroller and length is equal to 9.
    When response comes from server it contzins 9 objects and total = 33.
    Those 9 rows are disaplayed inside table but when I scroll down no more objects are loaded.

    What do you think?

  • WebCodexWebCodex Posts: 71Questions: 13Answers: 3

    Im not sure what your trying to achieve but you can limit the total like this:

            var out = [];
            var i = 0;
            var ien = 33;
    
            for (  i = 0; i < ien; i++ ) {
                out.push( [ i+'-1', i+'-2', i+'-3', i+'-4', i+'-5' ] );
            }
    
  • allanallan Posts: 63,230Questions: 1Answers: 10,417 Site admin

    My point is that the server is returning more data than there actually is - hence the error. If there are less rows than start + len for request, then only that limited set should be returned. Don't have it return rows that don't exist.

    Allan

This discussion has been closed.