Avoid datatable reload on initialization

Avoid datatable reload on initialization

wfatherhwfatherh Posts: 2Questions: 0Answers: 0
edited September 2013 in DataTables 1.9
Hello everyone

My page with datatable load twice - first time ordinary way, second (AJAX) triggered by datatable which means that my heavy server side reports run twice (a lot of time).

I'm trying to find some flag, properties etc. to avoid this behavior - no luck.

datatable is created by:

var dataTab=$('#tbl_rep').dataTable({
"bPaginate": false,
"bJQueryUI": true,
"aaSorting": [],
"bSortCellsTop": true
});

$('#tbl_rep') table already contains all data - no needs to trigger ajax request, also I don't need pagination in this case.

I will be very grateful for some hints.

Best regards,
Wojtek

Replies

  • metateckmetateck Posts: 10Questions: 0Answers: 0
    Our problems sound very similar. I am going to watch your thread for a solution as well (and it might help you to bookmark my thread as well), and wanted to warn you of a possible bug I discovered related to this matter. The two requests may be getting appended to each other. See here for more information

    http://datatables.net/forums/discussion/17552/prevent-initial-datatables-load#Item_3
  • miguel2k10miguel2k10 Posts: 1Questions: 0Answers: 0
    The following will disable the initial load of your table.

    [code]"iDeferLoading": 0,[/code]
  • metateckmetateck Posts: 10Questions: 0Answers: 0
    I believe that iDeferLoading only works when bServerSide is set to true. Is there an alernative solution for leaving bServerSide set to false?
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    Currently no - there is no way to defer loading of Ajax data with client-side processing. It is something I looked at adding for 1.10, but was surprisingly complex to do, so I hasn't yet been implemented. iDeferLoading is only suitable for use with server-side processing enabled. I will make that explicit in the docs.

    Allan
  • wfatherhwfatherh Posts: 2Questions: 0Answers: 0
    Finally I found reason of that strange behavior.... I made stupid bug one line after datatable initialization:

    $('.dataTables_wrapper .ui-toolbar').css('background','url()');

    I intended to remove header background (I know - stupid way), but I didn't realized that empty url means current url - so in fact I trigger reload page.

    I'm sorry to waste your time and thank you for every response.

    BTW datatable is awesome.

    Best regards
    Wojtek
  • allanallan Posts: 63,383Questions: 1Answers: 10,449 Site admin
    > didn't realized that empty url means current url

    I spend 2 days debugging something like that in an embedded environment once. Urgh!

    Good to hear you got the issue resolved.

    Allan
This discussion has been closed.