scrolling to bttom of table not working

scrolling to bttom of table not working

emann3emann3 Posts: 6Questions: 2Answers: 0

trying to get datatables to scroll to the bottom row.

my code:

        transactions_table.on('draw', function () {
            var num_rows = transactions_table.data().length;
            //transactions_table.scroller.toPosition(num_rows - 1);
            transactions_table.row(num_rows - 1).scrollTo();
        });

I have tried either of the 2 lines toposition() and scrollto() and neither works, the table just stays at the top row.

paging, searching, ordering, info are all set to false.

I have tried replacing the "num_rows-1" with just the number 100, still no scroll.

The num_rows variable does get set to the correct # of rows in the data, so the issue is with the scrolling.

Not sure what I'm missing.

Thanks

Answers

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited October 2018

    Your code, using transactions_table.scroller.toPosition(num_rows - 1);, seems to work here:

    http://live.datatables.net/xibehuwa/1/edit

    Maybe you can update the test case to replicate your issue.

    Kevin

  • emann3emann3 Posts: 6Questions: 2Answers: 0

    Thanks,

    As soon as I put paging:false in that test case, all the data disappears.

    What am I missing about paging?

    If I remove paging:false from my app, I get a paged table, which I don't want.

  • emann3emann3 Posts: 6Questions: 2Answers: 0

    actually , i had to hit "run with javascript" to get the data back.

    but now, with paging: false, the scroll to bottom is broken?

    it looks like it has something to do with when on draw is called?

    IF I hit "run with javascript" button, data is refreshed, but scrolling doesn't happen.

    If I hit the live preview to pop-out, the scroll works.

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    I can't seem to find it but I do believe scroller needs to have paging enabled. My understanding is that it using the paging to help calculate the rows. @allan can confirm this though.

    Is there a reason you want to disable paging?

    Kevin

  • emann3emann3 Posts: 6Questions: 2Answers: 0

    yes, at one point, running the test case and doing the pop-out ,I got a dt error box saying paging needed to be enabled to use scroller (but I didn't get it all the time?)

    I want to not have pages as I need to show all transactions in a scroller. I found where it says I can set page.len(-1) and it should show all rows, but it still shows the page number and goto boxes which doesnt look clean.

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    You can remove the paging buttons and page length option using the dom option. Just don't include those in the option string.

    Kevin

This discussion has been closed.