-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Records out of order whilst using Chrome #225
Comments
I'm having the same issue with Chrome. I'll page back and forth between pages and the some of the records will change. I wonder if the issue has to do with using Array.sort, where apparently Chrome, Firefox and Safari use different sort algorithms and Chrome's sort algorithm may return different results each time. That's the impression I got from reading this http://blog.rodneyrehm.de/archives/14-Sorting-Were-Doing-It-Wrong.html |
Can anyone provide a live example of this happening? I don't believe it should have anything to do with the default sort algorithm of the browser, as the way dynatable handles this is by creating a So, it's literally sorting by an array of index integers, which should be both consistent and correct, no matter what the default sort algorithm of the browser is. If someone has a live example of this happening, maybe we can pinpoint what's going wrong (i.e. are the |
I have a page where I'm using the dynatable here at the bottom: http://mrr.devtechlab.com/mrr-dashboard.html |
@tehandyb, I took a look, and if you open the developer console on your page and inspect the records for the current dynatable page, e.g. the first record: $('#project-table-id').data('dynatable').settings.dataset.records[0] There is no So, if you're populating the records directly yourself from a JSON collection, dynatable doesn't mess with the properties of the JSON collection; since dynatable isn't responsible for building the JSON like it is when it has to build the collection from the table rows in the initial HTML, it plays it safe and doesn't mess with your JSON (e.g. by adding meta-data) collection that you explicitly passed in. Of course, that seems to lead us to our current issue where it doesn't seem to keep the order as you're paging back and forth. What's really weird though is that when you page back and forth, all dynatable is doing is slicing the records from that page out of the What I can't figure out is why the order of records in var dynatable = $('#project-table-id').data('dynatable');
//=> undefined
dynatable.settings.dataset.originalRecords[1].project_name
//=> "Value Chain activity."
dynatable.paginationPage.set(2); dynatable.process()
//=> undefined
dynatable.settings.dataset.originalRecords[1].project_name
//=> "Incentives Driving Economic Alternatives for the North, East, and West (IDEA-NEW)" Given that the order of a JSON array is preserved unless you actually change the array, and given that there is only one line in the entire dynatable source that sets the To answer the original question in this ticket, I don't know that there's any obvious fix, as I'm not sure that this behavior is being caused within the dynatable code. Hopefully this helps though and can lead someone to the solution. If anyone can do a bit more research and determine that there is something in dynatable causing this, or maybe just come up with an isolated example e.g. on jsfiddle or something, I'd be happy to figure out a fix. EDIT Also, if it further helps anyone debug this issue, what happens at the beginning of every sort/page/filter operation is that the working recordset is reset to the original recordset, and then the sorts, page slicing, and filters are applied. Even there, you can see the |
Jango Steve - thank you so much for helping me finally figure this out. Forcibly adding the attribute 'dynatable-original-index' to each of the records I was generating in my JSON fixed this problem in Chrome. I was experiencing this exact problem in Chrome only - all other browsers were honoring the exact order in which I was sending the records. Perhaps someone should consider amending the documentation to explain that if you are generating your OWN JSON and doing sorting on the server side, you should add a 'dynatable-original-index' value to each record in the JSON you generate and use that to index them in order? Because that certainly fixed the problem. As it stands, the documentation about the specifics of doing the server-side JSON generation was a bit sparse and I had to do a lot of trial-and-error before I could get most of it to work as expected. |
Is anyone able to provide more information on this? I'm still experiencing this issue in Chrome only, but unsure of what 'dynatable-original-index' is or how/where to use it. |
Hey Guys, This can be fixed by |
I had the same problem - JangoSteve's comment helped a ton. Thanks! |
Hey Guys,
I have noticed that the original order of json data is not being preserved whilst using Chrome, however, it is correct when using FireFox and Internet Explorer.
Is there an obvious fix for this?
Thank you,
Sam
The text was updated successfully, but these errors were encountered: