Reusing a table with server side processing

Reusing a table with server side processing

randgaltrandgalt Posts: 7Questions: 0Answers: 0
edited February 2012 in General
I have a table that is populated by server side processing. It also uses the Scroller "plugin". Note: the table is displayed in a JQueryUI dialog.

It works fine the first time I open it. But, if I scroll down a few pages, close the dialog and then re-open, the display is blank. I don't know how to reset the table/scroller so that it redisplays everything.

Replies

  • randgaltrandgalt Posts: 7Questions: 0Answers: 0
    * bump *
  • randgaltrandgalt Posts: 7Questions: 0Answers: 0
    OK - I just purchased an hour of support for this. How I do get that support?
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    edited February 2012
    Hi randgalt,

    Thanks very much for taking up the DataTables support option! Sorry I didn't get the opportunity to answer your question before.

    When you reopen the dialogue box, do you want the table to show the paging information where it was before, or to reset back to zero? Do you have a link to your page that you can give me, otherwise, I'll build a little example of how it much be done with Scroller.

    *edit* - a couple of additional questions - what is your data source for the table? Is it server-side processing, or Ajax source or something else? Are there any other options that you've enabled on the table?

    Regards,
    Allan
  • randgaltrandgalt Posts: 7Questions: 0Answers: 0
    [quote]do you want the table to show the paging information where it was before, or to reset back to zero?[/quote]
    I'd like everything reset - it's a new "session" of the dialog with different data, etc.

    [quote]what is your data source for the table?[/quote]
    Server side ajax

    [quote]allan said: Are there any other options that you've enabled on the table?[/quote]

    $('#index-query-results-table').dataTable({
    "bProcessing": true,
    "bServerSide": true,
    "bStateSave": false,
    "bFilter": false,
    "bJQueryUI": true,
    "bSort": false,
    "sScrollY": "300px",
    "sDom": "frtiS",
    "bDeferRender": true,
    "iDeferLoading": false
    });
  • randgaltrandgalt Posts: 7Questions: 0Answers: 0
    FYI - the Ajax URL changes every time. So, I set it prior to displaying the dialog:


    var settings = $('#index-query-results-table').dataTable().fnSettings();
    settings.sAjaxSource = "index/dataTable/" + indexName + "/" + indexHandle;
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    > I'd like everything reset - it's a new "session" of the dialog with different data, etc.

    In that case, what I think the best option would be is to destroy the table rather than trying to reuse the old one (since you would have to reset the sorting, filtering, etc).

    This can be done relatively trivially using the "bDestroy" option. So rather than getting the settings object and manipulating that, call a function that will reinitialise your table as a whole. For example:

    [code]
    function initTable (src) {
    $('#index-query-results-table').dataTable({
    "bDestroy": true,
    "sAjaxSource": src,
    "bProcessing": true,
    "bServerSide": true,
    "bStateSave": false,
    "bFilter": false,
    "bJQueryUI": true,
    "bSort": false,
    "sScrollY": "300px",
    "sDom": "frtiS",
    "bDeferRender": true,
    "iDeferLoading": false
    });
    }

    // Then when you want to change the Ajax source and reinitialise the table
    initTable( "index/dataTable/" + indexName + "/" + indexHandle );
    [/code]

    And that, I think, should do the business for you :-)

    Regards,
    Allan
  • randgaltrandgalt Posts: 7Questions: 0Answers: 0
    edited February 2012
    That solved the problem. Thanks.
This discussion has been closed.