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

Adding sorting to dtOptions causes the table data to be reloaded #101

Closed
MatiasKiuru opened this issue Oct 20, 2014 · 3 comments
Closed
Labels
Milestone

Comments

@MatiasKiuru
Copy link

Hello!

This is what I'm trying to do:
http://www.datatables.net/examples/basic_init/table_sorting.html

But there appears to be some kind of bug that refreshes the table after sorting columns when using "order" in dtOptions.

Steps to reproduce:

  1. Take your row click event example (or any other example should work) and add this line to it in order to add default ordering:
    $scope.dtOptions.order = [[1, "desc"], [0,"asc"]];
  2. Then sort the table by clicking on one of the columns and after that click on one of the rows.

You should observe that a request is sent to server to get the data and the table is reloaded.

@l-lin
Copy link
Owner

l-lin commented Oct 20, 2014

Nice catch! 👍
Mmh it's seems like it only happens when a $digest cycle is fired. Indeed, the directive will consider that a change has been made, thus refreshing the table.

@l-lin
Copy link
Owner

l-lin commented Jan 18, 2015

Solved with #146.

@l-lin l-lin closed this as completed Jan 18, 2015
@l-lin l-lin added this to the v0.3.1 milestone Jan 18, 2015
@fudali
Copy link

fudali commented Apr 5, 2017

Hello! It looks like I still experience this issue in v0.5.7. The issue is exactly the same as described and I think it might not be related to #146

EDITED: ok so the problem only occurs if you pass multi-column default sorting like this:
{ order: [[1, 'asc'], [2, 'desc']] }
or even one column but in a multi array like this:
{ order: [[1, 'asc']] }
but it works fine if you pass only one column in a single array:
{ order: [1, 'asc'] }

Found out by accident! Super weird :) In the documentation it's not mentioned you can pass a single array:
https://datatables.net/examples/basic_init/table_sorting.html

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

3 participants