Setting _iRecordsTotal post dom load?

Setting _iRecordsTotal post dom load?

oversteeroversteer Posts: 4Questions: 0Answers: 0
edited October 2011 in DataTables 1.8
I'd like to load data from the dom and then set _iRecordsTotal to a value other than the
number of rows loaded from the dom. Is there a post load function I can use to do this?

For example server side I have 20 rows and am showing 10 rows per page on the client.
I get the server to send the first 10 rows, but on the client it thinks that's all of it. I want
to make the plugin know that there is more data to come. With this approach I can't use
the builtin ajax data loading functionality.

What I'm trying to do is to add a datatables.net wrapper to a jsf h:dataTable, and control
lazy loading with ajax.

Thanks for any assistance.

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    There's some lazy loading functionality built into the app.

    http://www.datatables.net/ref#iDeferLoading

    [code]
    $(document).ready(function() {
    $('#example').dataTable( {
    "bServerSide": true,
    "sAjaxSource": "scripts/server_processing.php",
    "iDeferLoading": 57
    } );
    } );
    [/code]
  • oversteeroversteer Posts: 4Questions: 0Answers: 0
    Hi, I saw this in the documentation but I don't think it's going to be any help to me in
    this specific scenario. I've got tables with content that is mostly JSF tags so I don't think
    I can easily replace this with jQuery ajax requests loading json data from the server. I'm
    really just doing an experiment to see how easily I can enhance the basic jsf datatable
    with datatables.net features, such as row selection and pagination.

    If, on the server side, I pass the JSF datatable a list of 200 Department objects it will
    generate an html table with 200 rows. What I can do is limit the list to only what I want to
    be displayed, say 10 rows. Then when another page is selected from the paginator I can
    make a request to the server to re-render the table with the new page of data. I'm looking
    at some pretty large data sets so the key issues is that we lazy load at most 'page size'
    rows from the database at a time.

    The only problem being that because I've got a page size of 10 (no. rows on single page),
    and there are 10 rows in the DOM, the next page control is understandably disabled, the
    assumption is that it's job done. I want to be able to say 'actually there are 73 rows in
    total' - but this would need to be done after the DOM has been re-processed.

    So clearly what I'm attempting is a bit of a hack to say the least but I wanted to establish
    if I could preserve the investment in the existing code and bolt on some additional
    features comparitively easily. It's gotta be worth a try.

    I guess that if I can overcome this hurdle the next challenge will be getting the .dataTable()
    to re-process the DOM after I've re-rendered the DOM contents via ajax, but I will cross
    that bridge if or when I come to it!

    Thanks for your reply.
  • oversteeroversteer Posts: 4Questions: 0Answers: 0
    Noone with any ideas on how to do this?
This discussion has been closed.