How to redraw header without pulling ajax source again?

How to redraw header without pulling ajax source again?

akcsieakcsie Posts: 4Questions: 0Answers: 0
edited November 2010 in General
HI,

I'm using dataTables with Jquery UI Tabs. The problem I have is my table is set as display:none initially by UI tab, so dataTables will not be able to calculate column width. I try to setup fnAdjustColumnSizing or fndraw on tab click event, they both works, but they both initiate an extra ajax call to request data from server side which isn't necessary in my case, fnAdjustColumnSizing even duplicate the data in my table.

Is there a way to redraw table header(recalculate column width) without requesting data from ajax source again?

Thanks.

Replies

  • adamfeldmanadamfeldman Posts: 2Questions: 0Answers: 0
    I'm also running into this same issue. Is there a way to use fnAdjustColumnSizing without it triggering another ajax request for the data from the server?

    Thanks!

    Best,

    Adam
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Currently no - a draw, if using server-side processing will incur another Ajax request. You can use a buffer such as my pipelining example to combat this: http://datatables.net/release-datatables/examples/server_side/pipeline.html .

    Allan
  • mrullomrullo Posts: 5Questions: 0Answers: 0
    I'm running into the exact same issue, is there any possibility of adding a method to do the redraw without a refresh of the data?
  • jpakulskijpakulski Posts: 2Questions: 0Answers: 0
    edited December 2012
    This works, but seems a bit ugly:

    [code]
    // Create DataTable
    var data_table = $(this.targ).dataTable(this.options);

    // This method suspends ajax requests,
    // makes a call to whatever goodness is desired: fnDraw, fnAdjustColumnSizing,
    // then restores the previous setting
    this.data_table.reDrawNoAjax = function() {
    var ajax_data_get = this.dataTable.settings[0]['bAjaxDataGet'];
    this.dataTable.settings[0]['bAjaxDataGet'] = false;
    this.fnAdjustColumnSizing();
    this.dataTable.settings[0]['bAjaxDataGet'] = ajax_data_get;
    };

    // Use the new method (perhaps as part of a resize callback)
    data_table.reDrawNoAjax();
    [/code]

    Hope a real solution is added.
    Thank You
  • pierrick17pierrick17 Posts: 1Questions: 0Answers: 0
    Or you can do :

    [code]
    oTable.fnAdjustColumnSizing(false);
    [/code]

    Pierrick
This discussion has been closed.