1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default Format a date in a DataItem

    Format a date in a DataItem


    Hi

    I have this date "2012-02-08T00:00:00+01:00" which I would like to format, but I don't have a clue how to do this in this situation

    I'm using a Ext.DataView which uses a store and to render the records it uses a Ext.dataview.component.DataItem.

    The DataItem looks like:

    Code:
    Ext.define('MyApp.view.JobsListItem', {
        extend : 'Ext.dataview.component.DataItem',
        xtype : 'jobslistitem',
        requires : ['Ext.Img'],
    
    
        config : {
            margin : 30,
            dataMap : {
                getDate : {
                    setHtml : 'date'
                },
                getDescription : {
                    setHtml : 'description'
                },
                getCountry : {
                    setHtml : 'country'
                },
                getCity : {
                    setHtml : 'city'
                }
    
    
            },
    
    
            cls : Ext.baseCSSPrefix + 'list-item',
    
    
            description : {
                cls : 'name'
            },
    
    
            date : {
                cls : 'name'
            },
            country : {
                cls : 'name'
            },
            city : {
                cls : 'name'
            },
    
    
            layout : {
                type : 'hbox',
                pack : 'left'
            }
        },
        applyDate : function(config) {
            return Ext.factory(config, Ext.Component, this.getDate());
        },
        updateDate : function(newDate) {
            if(newDate) {
                this.add(newDate);
            }
        },
        applyDescription : function(config) {
    
    
            return Ext.factory(config, Ext.Component, this.getDescription());
        },
        updateDescription : function(newDescription) {
    
    
            if(newDescription) {
                this.add(newDescription);
            }
        },
        applyCountry : function(config) {
    
    
            return Ext.factory(config, Ext.Component, this.getCountry());
        },
        updateCountry : function(newCountry) {
    
    
            if(newCountry) {
                this.add(newCountry);
            }
        },
        applyCity : function(config) {
    
    
            return Ext.factory(config, Ext.Component, this.getCity());
        },
        updateCity : function(newCity) {
    
    
            if(newCity) {
                this.add(newCity);
            }
        }
    });
    and the store looks like

    Code:
    Ext.define('MyApp.store.Jobs', {
        extend : 'Ext.data.Store',
        requires : ['MyApp.model.Job'],
    
    
        config : {
            model : MyApp.model.Job',
            autoLoad : true,
            remoteFilter : true,
            proxy : {
                type : 'ajax',
                url : 'rest/job/list',
                reader : {
                    type : 'json',
                }
            }
        }
    });
    I have two questions.
    1) Where do I have to define the input-date format (In this particular case I think it is not necessarty, but I still would like to know!)
    2) where do I define the output date format

    Any help would be appreciated!

    Cheers
    Luca

    UPDATE: I do see now a warning which state that the model cannot parse the date-string into a valida date!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    853
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Isn't the date object the component config?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    139
    Vote Rating
    3
    jeanluca is on a distinguished road

      0  

    Default


    Do you mean I have to format the date somewher in here

    Code:
    getDate : {
        setHtml : 'date' 
    },
    ......
     applyDate : function(config) {       
            return Ext.factory(config, Ext.Component, this.getDate());  
     },
     .....
    updateDate : function(newDate) {
            if(newDate) { this.add(newDate);}    
    },
    .....
    If so, how. I was not able to get something useful out of the input values!

    cheers

Thread Participants: 1