[CLOSED] Store ModelField DateFormat error

  1. #1

    [CLOSED] Store ModelField DateFormat error

    Hi
    <ext:Store runat="server" ID="storeDeneme" DataSourceID="sdsDeneme">
                <Model>
                    <ext:Model runat="server" IDProperty="test_id">
                        <Fields>
                            <ext:ModelField Name="test_id" Type="Int" />
                            <ext:ModelField Name="tarih1" Type="Date" DateFormat="Y-m-d" />
                            <ext:ModelField Name="tarih2" Type="Date" />
                            <%--<ext:ModelField Name="tarih1" Type="Date" DateFormat="ddd, dd MMM yyyy HH:mm:ss T" />
                            <ext:ModelField Name="tarih2" Type="Date" DateFormat="ddd, dd MMM yyyy" />--%>
                        </Fields>
                    </ext:Model>
                </Model>
                <Listeners>
                    <Exception Handler="Ext.Msg.alert('Uyarı', response);" />
                    <Load Handler="console.log(this.config.model.fields[1])" />
                </Listeners>
            </ext:Store>
    output null. storeDeneme.config.model.fields[1].dateFormat --> Y-m-j

    <ext:ModelField Name="tarih1" Type="Date" DateFormat="ddd, dd MMM yyyy HH:mm:ss T" />
    output null. storeDeneme.config.model.fields[1].dateFormat --> D, d M Y H:i:s T
    What is wrong ?

    thank you good work.
    Last edited by Daniil; Dec 15, 2015 at 1:29 PM. Reason: [CLOSED]
  2. #2
    Hi @siyahgul,

    Running a page with the Store that you posted, I see dateFormat: "Y-m-j" in the output which is correct for:
    <ext:ModelField Name="tarih1" Type="Date" DateFormat="Y-m-d" />
    It is .NET date format string in markup, but it is translated to ExtJS data format string.
    http://docs.sencha.com/extjs/5.1/5.1...!/api/Ext.Date

    "Y" and "m" has the same meaning, but .NET "d" is a counterpart of "j" in ExtJS.
  3. #3
    Example http://docs.sencha.com/extjs/5.1/5.1...!/api/Ext.Date

    var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
    console.log(Ext.Date.format(dt, 'Y-m-d'));                          // 2007-01-10
    console.log(Ext.Date.format(dt, 'F j, Y, g:i a'));                  // January 10, 2007, 3:05 pm
    console.log(Ext.Date.format(dt, 'l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM
    My Page

    <ext:ModelField Name="tarih1" Type="Date" DateFormat="c" />
    
    <Load Handler="console.log(this.data.items[0].get('tarih1'));" />
    //output: Wed Dec 23 2015 00:00:00 GMT+0200 (Türkiye Standart Saati)
    <ext:ModelField Name="tarih1" Type="Date" DateFormat="Y-m-d" />
    
    <Load Handler="console.log(this.data.items[0].get('tarih1'));" />
    //output: null
    <ext:ModelField Name="tarih1" Type="Date" DateFormat="F j, Y, g:i a" />
    
    <Load Handler="console.log(this.data.items[0].get('tarih1'));" />
    //output: null
    <ext:ModelField Name="tarih1" Type="Date" DateFormat="l, \\t\\he jS \\of F Y h:i:s A" />
    
    <Load Handler="console.log(this.data.items[0].get('tarih1'));" />
    //output: null
    I can not get data out of c.
  4. #4
    I can not get data out of c.
    Do you mean that only DateFormat="c" works? If so, most likely it means that all other DateFormats that you try are wrong.

    A ModelField's DateFormat is to convert strings from the loaded data to dates.
  5. #5
    I found my solution. But it was difficult.

    <ext:ModelField Name="tarih1" Type="String" DateFormat="Y-m-d">
                                <Convert Handler="return Ext.Date.format(new Date(value), this.dateFormat).toString();" />
                            </ext:ModelField>
    
    <Load Handler="console.log(this.data.items[0].get('tarih1'));" />
    //output: 2015-12-22
    Last edited by siyahgul; Dec 14, 2015 at 11:56 AM.

Similar Threads

  1. [CLOSED] Error Creating control - chart modelfield
    By megatechboy in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 19, 2014, 8:52 PM
  2. [CLOSED] Filtering a store with a ModelField of Type Object
    By csfesta in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 18, 2013, 4:40 AM
  3. [CLOSED] ModelField DateFormat problem
    By mirwais in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 01, 2013, 12:40 PM
  4. [CLOSED] Version 1.2 Grid/Store DateFormat
    By ndotis in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Oct 04, 2011, 5:14 PM
  5. [CLOSED] DateFormat on store?
    By Dave.Sanders in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 15, 2011, 12:55 PM

Posting Permissions