Use Scroller without pagination?

Use Scroller without pagination?

marianopeckmarianopeck Posts: 53Questions: 8Answers: 0
edited October 2013 in General
Hi guys. I can't use the pagination provided by DataTables. Instead, I am using my own pagination, based on server side etc.. I would not like to change this now...Anyway, with the usage of DataTables, the header is fixed and always visible, which is very nice. Hence, I can usually have many rows displayed at the same time. Say, 1000, whatever. So I would love to use the Scroller there, but without using Pagination facilities. I tried to do it but I get a popup saying: "DataTables warning (table id = 'id32'): Pagination must be enabled for Scroller". I really don't understand why Pagination is mandatory. Cannot you simply consider the whole table as a page?

Anyway, any workaround is deeply appreciated.

Thanks!

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Scroller requires DataTables pagination to be enabled because Scroller effectively needs to split data into sections - i.e. the reason that needs to be drawn. It does that by manipulation of the start and page length of DataTables. There is a full description of Scroller here: http://datatables.net/blog/Introducing_Scroller_-_Virtual_Scrolling_for_DataTables .

    So no, there is no work around at the moment, and likely won't be one without a complete retooling of Scroller and possibly DataTables.

    Allan
  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    edited October 2013
    You can try the following as a workaround:

    In the CSS, set:

    div.dataTables_paginate {
    display:none;
    }

    That will make it so none of the pagination buttons show up.

    Then in the CSS, set:

    div.dataTables_length {
    display:none;

    }

    That will make it so the dropdown to select the number of rows per page does not show up.

    Finally, set the iDisplayLength to -1 in your js function:

    "iDisplayLength": -1

    That will make the default number of rows per page be set to all.

    Though, I'm not sure how it will work if you are still looking to do server-side pagination on your datatables tables. But this will allow you to display all the items without showing pagination features, while still using the scrollbar.
  • marianopeckmarianopeck Posts: 53Questions: 8Answers: 0
    Hi Allan/jgoulet

    I think the workaround of jgoulet is what I was looking for! And I don't use the server-side pagination of datatables. I mean, my app is server-side, I have my own pagination rendered OUTSIDE the html table... Each request goes to the server and the table is rendered on the client. So for the plugin point of view, all it gets is a table in the DOM, no matter if those elements are all, or a page, or what page etc...so I think this workaround is safe for my case, isn't it?
  • jgouletjgoulet Posts: 26Questions: 2Answers: 1
    Yeah, it sounds like it should work. I thought you meant that you were using php or something for a server-side pagination, which would be kind of strange for a client-side rendered table, haha.
This discussion has been closed.