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

Order double render and ajax request twice #295

Closed
Orvisky opened this issue Apr 24, 2015 · 3 comments
Closed

Order double render and ajax request twice #295

Orvisky opened this issue Apr 24, 2015 · 3 comments

Comments

@Orvisky
Copy link

Orvisky commented Apr 24, 2015

Hi,

i saw you fixed order bug here #146 , but i still have this issue in my datatables. I am using latest version of angular datatables and also jQuery datatables 1.10.

My configuration:

.withOption('serverSide', true)
.withOption('bDeferRender', true)
.withDataProp('data')
.withOption('processing', true)
.withOption('language', {processing: '<div class="router-animation-loader dataTableProcessing"><i
class="fa fa-gear fa-2x fa-spin"></i></div>'})
.withOption('autoWidth', false)
.withOption('sDom', 'l<"#datatablesSearch"f>rtip')
.withOption('footer', true)
.withOption('order', [[ 0, 'asc' ]])

On page load status:

  • table

image

  • network

image

After click on first header column (sort):

  • table

image

  • network

image

It looks like that table dont use it actual instance, but create new. As you can see there is 2 request send:

  • one with draw = 2 (this is actual instance, continuous incremenet of draw in URL)
  • second with draw = 1 (this is new instance, bugged)

Conclusion

When i remove .withOption('order', [[ 0, 'asc' ]]) everything work Okay.

@l-lin
Copy link
Owner

l-lin commented Apr 24, 2015

Mmh weird. I don't reproduce your issue. See this pen.

@Orvisky
Copy link
Author

Orvisky commented Apr 27, 2015

I fixed something, ordering is now not a problem.

But, i am using datatables and daterange picker. When i change date, i call $scope.dtOptions.reload = true; and this cause that two instances are created and twice ajax call are made.

Can you say me what exactly (or where in code angular-datatables.js) i can track this command $scope.dtOptions.reload = true; ?

Thank you

@l-lin
Copy link
Owner

l-lin commented Apr 28, 2015

There is a watcher on dtOptions. You can check the code here.
It should be called once though.

If you want to reload the data, you do not need to call $scope.dtOptions.reload = true;.
See the documentation for an example.

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

No branches or pull requests

2 participants