Giter VIP home page Giter VIP logo

Comments (9)

adamschwartz avatar adamschwartz commented on August 23, 2024

I’m fairly confident the issue is that Date.parse('1&1') returns the current date in Chrome whereas Firefox returns NaN. This is the imperfect criteria we use to decide if a column contains “date” data. We could introduce an attribute data-sortable-type which you could add to the th to force a specific data-type to Sortable, with current options numeric, alpha and date. For the time being though if you ensure that the entry in the first row of the “Host” column (call it foo) have a value such that Date.parse(foo) returns NaN, you should see this issue resolve. Hope this helps!

from sortable.

adamschwartz avatar adamschwartz commented on August 23, 2024

Turns out someone already suggested this in #21. This should be closed as a duplicate.

from sortable.

adamschwartz avatar adamschwartz commented on August 23, 2024

(I’d close it myself but no longer have admin privileges for some reason.)

@timmfin @geekjuice @TrevorBurnham @graysky a little help here?

from sortable.

adamschwartz avatar adamschwartz commented on August 23, 2024

Thanks @timmfin

from sortable.

felds avatar felds commented on August 23, 2024

@adamschwartz I'm working on an implementation that allows selecting the sort order via data-* attributes and also allows the user to add custom types and/or change how the types work. It has been pretty hard not to break BC and to keep the small footprint at the same time, but I think I'm getting there!

from sortable.

adamschwartz avatar adamschwartz commented on August 23, 2024

@felds Thanks, cool idea. Since window.Sortable.types and window.Sortable.getColumnType are already exposed, you could probably modify getColumnType slightly and you’d be pretty close. Hope this helps.

from sortable.

felds avatar felds commented on August 23, 2024

@adamschwartz
I made so that each type test the data to see if it matches its definition. (felds@f28945f)

It works, but it's not that easy defining new types, as it's not an object, but an array (so pushing a new type would append it to the list, after the default one).
Converting the array to an obj flips the problem: we cannot trust the obj order when iterating through its keys and the default type could come first on the loop.

I think a solution could be adding a "priority" key to the type obj, converting the types obj into an array before looping and then sorting by that property. Not that elegant, but I think that would work!

Any ideas?

from sortable.

adamschwartz avatar adamschwartz commented on August 23, 2024

Great idea! I think the array option is slightly better. See my couple comments, but I can’t wait to see the PR! Nice job. And thanks! 👍

from sortable.

jcolemorrison avatar jcolemorrison commented on August 23, 2024

Ran into this issue (that as mentioned above only occurs in chrome) due to it thinking any number is with a string is a valid date. Has anyone found a way, other than data-sortable-types in getting around Chrome's different way of dealing with Date.parse / new Date's?

from sortable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.