Skip to content
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

Integer sorting not working 0.3.1 #226

Open
Samuel1989 opened this issue Nov 1, 2015 · 2 comments
Open

Integer sorting not working 0.3.1 #226

Samuel1989 opened this issue Nov 1, 2015 · 2 comments

Comments

@Samuel1989
Copy link

Hey Guys,

I have read the previous issues around this and I have been unable to get this to work.

I have tried the following readers:

                                readers: {
                    'name': function(el, record) {
                        return Number(el.innerHTML);
                    }
                }

And the following writers:

                                writers: {
                    'name': function(record) {
                        return record.name.toString();
                    }
                }

But when I click the on the headers it still sorts them as if they were a string (9 being higher than 100 for e.g.).

Any help would be greatly appreciated.

Sam

@kmilligan
Copy link

I know this is an old thread, but I just ran into this issue; not sure that this applies to your case, but in my case, I discovered that if I am providing the records "manually" via dataset.records (instead of reading the data from an existing table) that the reader functions are not called -- so I ended up having to pre-process my JSON to convert the values to numbers before giving the records to dynatable.

@cameraki
Copy link

Same as @kmilligan.

My server side code is in PHP so I just converted the values before it was sent to dynatable.

In my case it was this:
(int)$order->getOrderId();

Using (int) to convert the values to an integer.

I did not use readers or writers, just added the (int) and it worked.

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

No branches or pull requests

3 participants