lajeesh k
lajeesh k

Reputation: 335

Ext Js panel empty time field

I am new to ext js I am sorry if I couldn't explain my problem properly

My problem is the time field in grid is displays as blank

It displays the value if change both the type to string from date in model and disable rendering function formatTime .

Below is the part of response json,model and view. I have copied the code from another working site.

Please tell me how can debugg and find the solution and what will be possible reasons

Extjs 4.2 mvc

Value in json response

"actualstarttime":"02:00 AM"

model

{name: 'actualstarttime',    type: 'date'}, 

View

                     {
                            header: 'Time',
                            dataIndex: 'actualstarttime',
                            width: 85,
                            renderer: this.formatTime,

                            editor: {
                                xtype: 'timefield',
                                id : 'e_actualstarttime',
                                /*allowBlank: false,*/
                                minValue: '12:00 AM',
                                maxValue: '23:00 PM',
                                increment: 30,
                                anchor: '100%',
                                editable : false,
                                format: 'h:i A',
                                submitFormat: 'h:i A',
                                listeners: {
                                    change: function(roweditor, changes, record, rowIndex) {
                                        me.calculateInterval(roweditor, changes, record, rowIndex);
                                    },
                                    afterrender: function( roweditor, changes, record, rowIndex ) { //TECHNOKRAFTS: Added Listner to apply validation depending on the status
                                        me.checkstatusvalidation(roweditor, changes, record, rowIndex);
                                    }
                                }
                            }   
                         }

Formattime function called in render

formatTime : function (value){
    return value ? Ext.Date.dateFormat(value, 'g:i A') : '';
}

Upvotes: 0

Views: 408

Answers (1)

Bojan Dević
Bojan Dević

Reputation: 1875

You need to add the dateFormat to your field definition.

    Ext.define("Model", {
        extend: "Ext.data.Model",
        fields: [{
            name: "actualstarttime",
            format: "h:i A"
        }]
    });

Demo

Upvotes: 1

Related Questions