Comments (6)
Server- or clientside? Do you work with the master branch? If sorted incorrectly or any exception thrown?
Maybe should I implement the possibility to set the columns.type (http://datatables.net/reference/option/columns.type).
from datatablesbundle.
I've just updated to the latest master of this bundle, and my server-side based doesn't throw any exceptions. It's just ascii ordering the 'timeago' strings -
- "25 days ago"
- "4 days ago"
- "8 days ago"
- "8 hours ago"
- "9 days ago"
- "a month ago"
If there is some way that original date can be put for the sort field (as an epoch, or probably better, an ISO date), and the sort would base of of that, then it would probably be fine.
from datatablesbundle.
You can try the following in the render_timeago
function (datatable.html.twig):
function render_timeago(data, type, row, meta) {
if ("display" === type) {
if (typeof data.timestamp != "undefined") {
moment.lang("{{ app.request.locale }}");
return moment.unix(data.timestamp).fromNow();
} else {
return null;
}
}
return data;
}
Unfortunately, we now have still a problem with the filter. The user would have to enter a date for that.
from datatablesbundle.
I've overridden the template (verifying it's being called OK), and changed the 'render_timeago' function, as above. The only difference I can see afterwards is that the column is now unsortable.
from datatablesbundle.
Ok ... I can not reproduce the issue (at the moment). I have a table of all users and let me show the last login as Timeago. The result:
- a few seconds ago
- 2 days ago
- 2 months ago
- 2 years ago
or
- 2 years ago
- 2 months ago
- 2 days ago
- 3 minutes ago
Please save the link from http://debug.datatables.net/ start the Debug and go to Tables->Columns->Full column details->Your Timeago Column()
Show me the result. Thank you.
from datatablesbundle.
I've just realised that it was not in fact a ServerSide(true) based system, so I have split into index and results actions to enable that. The timeago field does now sort properly with the updated template, though all the sorting is only page based - so in order to see the highest or lowest dates I would have to view all entries.
Oddly, I also have to enable a primary key column, though it does not have to be visible, or else the sort appears to just reverse the order that is on screen, without any change in the ordering by the column that is clicked.
from datatablesbundle.
Related Issues (20)
- Basic sample configuration in Symfony5. Someone? HOT 3
- Custom DateTimePicker HOT 1
- Disable translation of selectFilter entries
- Showing all entries does not work HOT 2
- Edit inline selected value missing HOT 1
- Notice: Array to string conversion in search VirtualColumn HOT 4
- Calling setHint() on the Query
- Support for the v1.x HOT 4
- parent recursive
- SetMaxResult HOT 1
- Individual Filtering error HOT 1
- Array to string conversion in search VirtualColumn HOT 1
- Problem with dql, filter and global search
- Undefined constant Doctrine\DBAL\Types\Type::DATETIME HOT 4
- Bug on function getName() HOT 3
- Hidden DateTimeColumn is all empty when switched to visible until reload HOT 1
- Symfony 6.0 support HOT 3
- Search in translate value of VirtualColumn HOT 1
- Does MultiselectColumn require or use the Select extension? HOT 2
- Invalidate Result cache? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datatablesbundle.