Giter Club home page Giter Club logo

Comments (5)

mbucas avatar mbucas commented on August 25, 2024 1

I had the same problem, because file sizes where formatted server-side.
However I found looking at the sources of the sort function of Simple-DataTables [1] that it can use an attribute "data-content" to sort data instead of the content of the cell which includes KB, MB, ...
So I've put the bytes file size in this attribute and now the sort uses it (note that I count 1024 bytes in 1 KB) :

 <td data-content="162155197" align="right">154.6&nbsp;MB</td>

It'd be nice if it appeared in the wiki !

[1] https://github.com/fiduswriter/Simple-DataTables/blob/db3671f2a5c43c16122e0a48b19c85d3a7f5cc10/src/columns.js#L364

from simple-datatables.

johanneswilm avatar johanneswilm commented on August 25, 2024

Is this a feature you would like to program @weilinzung ? If so, we could add it.

from simple-datatables.

Stoakes avatar Stoakes commented on August 25, 2024

Hello,

I've been dealing with similar issue for an hour before eventually finding this thread, which greatly helped me. Thanks to you all.

So commenting here for search engines: data-content in Simple-Datatables is equivalent to DataTables data-sort or data-order

EDIT April 2024: The answer above was valid for simple-datatables < 6.0.0

When using a version >= 7.0.3, you must use data-order, as described in Getting started

from simple-datatables.

teemue avatar teemue commented on August 25, 2024

How do you actually set the data-content-value? I tried to set it after datatable.rows().add() but it gets cleared after sorting the column.

from simple-datatables.

Stoakes avatar Stoakes commented on August 25, 2024

My HTML is generated server side, so data-content come from there.

from simple-datatables.

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.