Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List.js - By date sorting issue

In my application I am using the List.js for sorting purpose. All the "string" values are working fine. But I do have the "modified date" in the column.

When I click "modified by date" - to sort, this is just considering the date values what is there is the text, ex: 1/4/11.. and sorting accordingly. because of this approach I am getting wrong sort orders.

how can I make instead it should sort by the real value of the number's what the dates are?

Here is my code:

new List('mfi-col2', {
       valueNames: ['companyLegalName', 'phazeName', 'contactName', 'number', 'enrollId', 'accountType']
                        });

Instead of "number" is it possible to send $(".number").data-number? So let it use the time stamp that I am getting from server?

Or can anyone suggest an alternative for this plugin?

like image 464
3gwebtrain Avatar asked Jun 07 '13 15:06

3gwebtrain


1 Answers

You could use a data-attribute, too:

js

valueNames: ['date', { name: 'timestamp', attr: 'data-timestamp' }

html

<td class="date timestamp" data-timestamp="1427713871">30/03/2015</td>

Now you are able to sort via timestamp without a second or hidden field.

like image 180
zeamedia Avatar answered Sep 29 '22 13:09

zeamedia