Skip to content
This repository has been archived by the owner on Feb 2, 2025. It is now read-only.

Double request with server side #146

Closed
hfgbarrigas opened this issue Dec 9, 2014 · 3 comments
Closed

Double request with server side #146

hfgbarrigas opened this issue Dec 9, 2014 · 3 comments
Labels
Milestone

Comments

@hfgbarrigas
Copy link

Hi,

Im using the latest version of angular-datatables and, noticed that there's a double request with server side... I traced the error to the following snippet:

$timeout(function () {
    DTRendererService.hideLoading($elem);
    // Condition to refresh the dataTable
    if (oTable) {
        var ajaxUrl = options.sAjaxSource || options.ajax.url || options.ajax;
        console.info("Loading data! ");
        oTable.ajax.url(ajaxUrl).load();
    } else {
        oTable = DTRendererService.renderDataTableAndEmitEvent($elem, options, $scope);
    }
}, 0, false);

For the moment i commented the timeout being applied... can you explain me why are you using $timeout (i understand that you're trying to force the rendering of datatables but removing the timeout has no repercussions) ?

o_12e9c14762e94d31-1

PS: Ignore the 500 status... servers down...

@l-lin
Copy link
Owner

l-lin commented Dec 9, 2014

The $timeout is, as you said, used to execute the DataTable function after Angular has finished its digest.
In lots of data, you will notice that removing this $timeout will not render your table.

Issue related to #102.

@hfgbarrigas
Copy link
Author

Can you define "lots of data" ? Since im using server side, the user will not get more than 100 rows per page. Do you mean expensive requests? Im not using sAjaxSource nor Object for "ajax" but a function. I define an option "ajax" that receives my custom function. This scenario was not contemplated? Finally, do you suggest a possible solution?

l-lin added a commit that referenced this issue Dec 9, 2014
@l-lin
Copy link
Owner

l-lin commented Dec 9, 2014

Yep, you were right. It was unecessary for the ajax renderer.
Fixed it. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants