Giter Site home page Giter Site logo

Comments (2)

tiliv avatar tiliv commented on July 30, 2024

Hm... does the middle argument of the column definition correctly reflect a database value, or is it computed via a method?

It sounds like the code is deciding it's not a real database field, and it's manually sorting by post-processed version of the data.

To prevent this, make sure the value's model field is correctly specified as part of the column definition:

datatable_options = {
    'columns': [ ('My Field', 'path__field', helpers.callback("{0:,}")) ],
}

If the field is calculated and not actually available at the query level, you can specify a model method/property name, and then you'll have to return a 2-tuple of data from your datatable callback so that it knows what is "formatted" and what is "raw":

datatable_options = {
    'columns': [ ('My Field', 'path__field', helpers.callback("{0:,}")) ],
}
def get_column_My_Field_data(self, obj, *args, **kwargs):
    text = "{0:,}".format(obj.path.field)
    return (text, obj.path.field)

I think this managed to escape full documentation. I'll see what I can do to add that in. It's not the kind of thing you want to be forced into doing often, but let me know if it changes anything.

from django-datatable-view.

bmatzelle avatar bmatzelle commented on July 30, 2024

Hm... does the middle argument of the column definition correctly reflect a database value, or is it computed via a method?

It's computed by a method.

If the field is calculated and not actually available at the query level, you can specify a model method/property name, and then you'll have to return a 2-tuple of data from your datatable callback so that it knows what is "formatted" and what is "raw"

Excellent! Thanks for the help!

from django-datatable-view.

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.