Results 1 to 3 of 3

Thread: Format a date in an groupingfeature

  1. #1
    Sencha Premium User
    Join Date
    Nov 2012
    Location
    Austria
    Posts
    55
    Answers
    1

    Question Answered: Format a date in an groupingfeature

    Hi,

    i hope you guys can help me.

    I'm searching for a possibility to show a date formated in an grouping-header of an grid.

    https://fiddle.sencha.com/fiddle/70s

    If you group the "Date" - Field in this fiddle, you can see the unformated date - value.

    Is there a way to show that header in a format like "d.m.Y".

    Best regards,
    Sebastian

  2. Here is where i found my solution:

    http://docs.sencha.com/extjs/4.2.1/#...groupHeaderTpl

    You could similarly format your date that way.

    Here is how i solve my problem:

    PHP Code:
    groupHeaderTplExt.create('Ext.XTemplate',    '{columnName}: {name:this.formatName}'    
    {        formatName: function(name) {
                     function 
    isValidDate(value
                    {
                       var 
    dateWrapper = new Date(value);
                        return (
    typeof value == 'object')&&(!isNaN(dateWrapper.getDate()));
                    }

                 if (
    isValidDate(name)){ return Ext.Date.format(name'd.m.Y');}
                 else return 
    name.toLocaleString();       
               }    



  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    Duplicate, response and user solution posted on this thread.
    http://www.sencha.com/forum/showthread.php?287915

  4. #3
    Sencha Premium User
    Join Date
    Nov 2012
    Location
    Austria
    Posts
    55
    Answers
    1

    Default

    Here is where i found my solution:

    http://docs.sencha.com/extjs/4.2.1/#...groupHeaderTpl

    You could similarly format your date that way.

    Here is how i solve my problem:

    PHP Code:
    groupHeaderTplExt.create('Ext.XTemplate',    '{columnName}: {name:this.formatName}'    
    {        formatName: function(name) {
                     function 
    isValidDate(value
                    {
                       var 
    dateWrapper = new Date(value);
                        return (
    typeof value == 'object')&&(!isNaN(dateWrapper.getDate()));
                    }

                 if (
    isValidDate(name)){ return Ext.Date.format(name'd.m.Y');}
                 else return 
    name.toLocaleString();       
               }    



Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •