see docs:

http://mootools.net/docs/more/Interface/HtmlTable.Sort#HtmlTable:defineParsers

HtmlTable.defineParsers({
//this is the default date parser; alter to suit your needs
'custom-date': {
 match: /^\d{2}[-\/ ]\d{2}[-\/ ]\d{2,4}$/,
convert: function() {
var d = Date.parse(this.get('text').stripTags());
 return $type(d) == 'date' ? d.format('db') : '';
},
 type: 'date'
}
});

Note that this is NOT an instance method. Not "myTable.defineParser" - it's
a static method on the HtmlTable namespace.

On Thu, Feb 10, 2011 at 9:07 AM, hamburger <[email protected]> wrote:

> sorry, i don't get it
> i tried this without any result:
>
>
> var myTable = new HtmlTable($('theTable'),
>        {sortable: true,
>         zebra: true,
>         classZebra: "zebra",
>         classHeadSort:"downArrow",
>         classHeadSortRev :"upArrow",
>         classCellSort:"focusedColumn"
>          });
>
> myTable.sort(0, true, false);
>
> // to parse to: 31. Januar 2011 - 23:29:07
>
> myTable.Parsers = {
> 'date': {
> match: /^\d{2}[.\/ ]\A[-\/ ]\d{2,4}$/,
> convert: function(){
> var d = Date.parse(this.get('text').stripTags());
> return (typeOf(d) == 'date') ? d.format('db') : '';
> },
> type: 'date'
> }
> };
>
>
> myTable.defineParser = function(parsers){
>        myTable.Parsers = Object.append(myTable.Parsers, parsers);
>            };
>
>
> On 10 Feb., 17:28, Aaron Newton <[email protected]> wrote:
> > Look in HtmlTable.Sort.js
> >
> > https://github.com/mootools/mootools-more/blob/master/Source/Interfac...
> >
> > There's even a method defined for you to add another:
> >
> > https://github.com/mootools/mootools-more/blob/master/Source/Interfac...
> >
> > Just pass it an object like the others.
> >
> > On Thu, Feb 10, 2011 at 6:24 AM, hamburger <[email protected]> wrote:
> > > Hello,
> > > i have a problem with my table i would like to sort by date.
> > > my first collum is a date like  31. Januar 2011 - 23:29:07
> > > but it sorts it by 31 not by date.
> > > the docs says that it will be sorted by date and it mentiones
> > > something by parsers what i do not understand.
> >
> > > my code:
> >
> > > var myTable = new HtmlTable($('theTable'),
> > >        {sortable: true,
> > >         zebra: true,
> > >         classZebra: "zebra",
> > >         classHeadSort:"downArrow",
> > >         classHeadSortRev :"upArrow",
> > >         classCellSort:"focusedColumn",
> > >         });
> >
> > > where or how can i add the parser here?
> > > thanks for help in advance
>

Reply via email to