Results 1 to 2 of 2

Thread: Date type from model does not receive a value from Form (Always null) Extjs 6.1 GPL

  1. #1
    Sencha User
    Join Date
    Nov 2010
    Location
    Villaflores,Chiapas,Mexico
    Posts
    97
    Answers
    9

    Default Date type from model does not receive a value from Form (Always null) Extjs 6.1 GPL

    Hi to all , i'm using SA 4.1.0.32 and Extjs 6.2 GPL
    and i have the next model:
    Code:
    Ext.define('HiplotTM.model.Tareas', {
        extend: 'Ext.data.Model',
    
    
        requires: [
            'Ext.data.field.Date',
            'Ext.data.field.Boolean'
        ],
    
    
        fields: [
            {
                name: 'id'
            },
            {
                name: 'Tarea'
            },
            {
                type: 'date',
                name: 'Fecha_creacion',
                dateFormat: 'MS'
            },
            {
                name: 'Idusuario_tarea'
            },
            {
                name: 'Observaciones'
            },
            {
                type: 'boolean',
                name: 'Finalizada'
            },
            {
                name: 'IdSucursalTarea'
            }
        ]
    });
    The field Fecha_creacion is a date type and my app is using MS SQL database.
    And this is my Form:
    Code:
    {
                xtype: 'form',
                modal: true,
                autoShow: true,
                height: 260,
                width: 683,
                bodyPadding: 10,
                items: [
                    {
                        xtype: 'fieldset',
                        height: 188,
                        items: [
                            {
                                xtype: 'textfield',
                                anchor: '100%',
                                fieldLabel: 'Tarea',
                                name: 'Tarea'
                            },
                            {
                                xtype: 'datefield',
                                itemId: 'edtFechaTarea',
                                width: 257,
                                fieldLabel: 'Fecha',
                                name: 'Fecha_creacion'
                            },
                            {
                                xtype: 'textareafield',
                                anchor: '100%',
                                height: 82,
                                fieldLabel: 'Actividaddes realizadas',
                                name: 'Observaciones'
                            },
                            {
                                xtype: 'hiddenfield',
                                anchor: '100%',
                                itemId: 'id',
                                fieldLabel: 'Label',
                                name: 'Idtarea'
                            }
                        ]
                    }


    The problem is when i create a new record, and save it:
    Code:
    var win    = button.up('window'),
    form   = win.down('form'),
    record = form.getRecord(),
    values = form.getValues();
    record = Ext.create('HiplotTM.model.Tareas');
    record.set(values);
    The field Fecha_creacion from Model always gets null value,
    but if i change the type in the model to auto or string, all values from the form field works perfect.


    This is a bug?

    Thank you and Happy new year.
    Last edited by icebergdelphi; 2 Jan 2017 at 6:27 AM. Reason: Versión

  2. #2
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64

    Default

    Well, you have specified dateFormat: 'MS' for your model date field. form.getValues() actually calls getSubmitValue for each form field. And your form date field will return a date string in the following format "m/d/Y" by default. So setting submitFormat: 'MS' for your form date field should solve the problem..

Similar Threads

  1. phonegap with Date model type
    By alonlevi in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 4 Sep 2013, 1:19 PM
  2. Replies: 2
    Last Post: 10 Jan 2012, 1:13 AM
  3. How to use Date model type with ComponentView
    By slrobertson1 in forum Sencha Touch 2.x: Q&A
    Replies: 1
    Last Post: 27 Dec 2011, 11:10 AM

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
  •