Hello webix team,
Please refer attached snippet.
https://snippet.webix.com/vxvrkqkg
Here, I’ve to sort Date column for the given format. Please provide solution for the same.
Hello webix team,
Please refer attached snippet.
https://snippet.webix.com/vxvrkqkg
Here, I’ve to sort Date column for the given format. Please provide solution for the same.
Thank you so much @AlenaLisava for the given solution.
Hello, @Pooja
Method sort:"date"
works just with Date objects, so initial data should be formatted via parsing method inscheme
:
scheme:{
$init:function(obj){
const parser = webix.Date.strToDate("%D %M %d %h:%i:%s %Y");
obj.date = parser(obj.date);
}
},;
Then you could use sort:"date"
to perform data sorting.
To present data in an initial format, use parsing method
again, but as a template
:
template:function(obj){
const parser = webix.Date.dateToStr("%D %M %d %H:%i:%s %Y");
return parser(obj.date); }
Here is an example: Code Snippet
Please, pay attention, Webix doesn’t handle the TimeZones, so this solution is provided for a string such as Thu Mar 11 14:56:39 2021
.
To have a solution with TimeZone included, you probably should use some library for parsing/formatting dates, for example, Moment.js (the overall approach, in this case, stays the same).