Перейти к содержимому


Фотография
- - - - -

Table Sorter for days of the week


Лучший Ответ Kess , 18 June 2014 - 11:24

Hello,

 

I've tried to implement this - http://tablesorter.c...le-parsers.html  and it works fine.

 

So here is how my days-of-week element look like:

 

days4352_200x0.png

 

Then I changed tablesorter initialization script in this file by adding parser for days:

media/zoo/applications/jbuniversal/templates/catalog/renderer/item_columns/database.php

 

So it looks like this now:

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery.tablesorter.addParser({ 
        id: 'days', 
        is: function(s) { 
            return false; 
        }, 
        format: function(s) { 
            return s.toLowerCase().replace(/monday/,1).replace(/tuesday/,2).replace(/wednesday/,3).replace(/thursday/,4).replace(/friday/,5).replace(/saturday/,6).replace(/sunday/,7); 
        }, 
        type: 'numeric' 
    }); 
     
    jQuery(function() { 
       jQuery(".jsTableSorter").tablesorter({ 
            headers: { 
                6: { 
                    sorter:'days' 
                } 
            } 
        }); 
    });   
});
</script>

Here is the result:

 

days5434_200x0.png

Перейти к сообщению


  • Закрытая тема Тема закрыта
Сообщений в теме: 2

#1 soundavman

soundavman

Отправлено 17 June 2014 - 18:57

Wonder if anyone can help. I've created a table system for an "exercise class" date system. It's functioning pretty well.

The only thing is that I have each class with a field for day of the week, e.g. Monday, Tuesday etc.

 

When I click the sort in the table header, it organises them alphabetically. Is there any way to organise them by date?


  • 0

#2 Kess

Kess

Отправлено 18 June 2014 - 11:24   Лучший Ответ

Hello,

 

I've tried to implement this - http://tablesorter.c...le-parsers.html  and it works fine.

 

So here is how my days-of-week element look like:

 

days4352_200x0.png

 

Then I changed tablesorter initialization script in this file by adding parser for days:

media/zoo/applications/jbuniversal/templates/catalog/renderer/item_columns/database.php

 

So it looks like this now:

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery.tablesorter.addParser({ 
        id: 'days', 
        is: function(s) { 
            return false; 
        }, 
        format: function(s) { 
            return s.toLowerCase().replace(/monday/,1).replace(/tuesday/,2).replace(/wednesday/,3).replace(/thursday/,4).replace(/friday/,5).replace(/saturday/,6).replace(/sunday/,7); 
        }, 
        type: 'numeric' 
    }); 
     
    jQuery(function() { 
       jQuery(".jsTableSorter").tablesorter({ 
            headers: { 
                6: { 
                    sorter:'days' 
                } 
            } 
        }); 
    });   
});
</script>

Here is the result:

 

days5434_200x0.png


Сообщение отредактировал Kess: 18 June 2014 - 11:26

  • 0

#3 soundavman

soundavman

Отправлено 01 July 2014 - 20:00

Brilliant, got this working. No probs. Thanks for your excellent help.


  • 0




Click to return to top of page in style!