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

X time ago sorting as string instead of moment #30

Closed
Melcus opened this issue Apr 11, 2016 · 1 comment
Closed

X time ago sorting as string instead of moment #30

Melcus opened this issue Apr 11, 2016 · 1 comment
Labels

Comments

@Melcus
Copy link

Melcus commented Apr 11, 2016

The created_at attribute is being passed as a moment object, but it's being parsed as string.

http://i.imgur.com/41xOvDO.png

 ready: function(){
        this.$http.get('/api/footage')
            .then(function(response){
                footages = response.data
                footages.forEach(footage => {
                        footage.created_at = moment(footage.created_at).fromNow()
                })
                this.tableData = footages
            }.bind(this))
    },

Also, how do I set Added to sort by default descending? Thanks in advance

@matfish2
Copy link
Owner

A. You are NOT passing moment objects but rather a string, by calling fromNow.
The plugin currently supports only absolute date formatting (see the dateFormat option). I may add relative formatting in the future.
In the meantime you can use two date columns: one absolute, sortable, and another, relative, created by a template. Check out the demo for an example: https://jsfiddle.net/matfish2/f5h8xwgn/
B. use the orderBy option. See the options API.

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

No branches or pull requests

2 participants