angular-data-grid / angular-data-grid.github.io

Light and flexible Data Grid for AngularJS applications.
http://angular-data-grid.github.io/demo/bootstrap/
112 stars 50 forks source link

Major bug - index ordering #64

Open zorta86 opened 7 years ago

zorta86 commented 7 years ago

I you use $index to return the current row index, it will be binded to the "actual" index instead of the "real" index. Case: sort A-Z, first row correctly display $index = 0. Now order Z-A, first row is a "z..." element and its index is 0. WRONG

$index should be maintained, you must work to ensure sorting algorithm won't touch index order.

Regards

AndreyChayko commented 7 years ago

@zorta86 , If I understand you correctly, you are expecting to see $index equals to 5, if you for instance have 5 items in a list and sorted them with Z-A sort. In this case it won't be such way, because each time you use filter or sort you are dealing with the new created list, and angular tries to re-render ng-repeat each time the collection is changed, and of course it causes the $index to be rebuilt again. To reach the behaviur you described you have to add a property INDEX inside your collection for each element and in this case it will work as you expecting.

P.S. In case if I'm not understand you correctly, please attach a code sample

zorta86 commented 7 years ago

yes you understand correctly. But I have a project that act just like I expect with just a simple ng-repeat and some UI components, maybe I can help you to solve this issue (or just implement it as a feature).

On Sep 29, 2017 19:01, "AndreyChayko" notifications@github.com wrote:

@zorta86 https://github.com/zorta86 , If I understand you correctly, you are expecting to see $index equals to 5, if you for instance have 5 items in a list and sorted them with Z-A sort. In this case it won't be such way, because each time you use filter or sort you are dealing with the new created list, and angular tries to re-render ng-repeat each time the collection is changed, and of course it causes the $index to be rebuilt again. To reach the behaviur you described you have to add a property INDEX inside your collection for each element and in this case it will work as you expecting.

P.S. In case if I'm not understand you correctly, please attach a code sample

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular-data-grid/angular-data-grid.github.io/issues/64#issuecomment-333181690, or mute the thread https://github.com/notifications/unsubscribe-auth/AHaPAOSPw6ZWyVZiqfq4NPO3ruPwK1g-ks5snSJzgaJpZM4Poxtn .

AndreyChayko commented 7 years ago

@zorta86 , Sure you can create a pull request to review for us Thanks