PDA

View Full Version : editor timefield submit value problem



jabbapl
29 Mar 2014, 11:44 PM
Hi Everyone

have a problem with subitted value from timefield in grid.

format is set to 'H:i' but returned value to the server and to renderer look like :

Tue Jan 01 2008 05:00:00 GMT+0100 (Central Europe Standard Time)

is that normal behavior ?

have column in grid:

{
xtype: 'gridcolumn',
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
console.log(value); //for checking displayed value
console.log(record);


return value;
},
width: 68,
dataIndex: 'time',
text: 'Hour',
editor: {
xtype: 'timefield',
width: 100,
fieldLabel: 'Label',
hideLabel: true,
editable: false,
format: 'H:i',
increment: 30,
submitFormat: 'H:i'
}



on cellEditing have:



onCellEditingEdit: function(editor, e, eOpts) {
id=editor.grid.getSelectionModel().getSelection()[0].get('id');
Ext.Ajax.request({
url : 'app/data/update.php' ,
params : { id:id,field:e.field,value:e.value },
method: 'GET',
success: function ( result, request ) {
var res=Ext.JSON.decode(result.responseText);

} });}

Best Regards
Martin

jabbapl
30 Mar 2014, 12:37 AM
solution:

{
xtype: 'gridcolumn',
renderer: function(value, metaData, record, rowIndex, colIndex, store, view) {
var timeval = new Date(value);
if(timeval!='Invalid Date') return Ext.util.Format.date(timeval,'H:i'); else return value;
},
width: 68,
dataIndex: 'time',
text: 'Hour',
editor: {
xtype: 'timefield',
width: 100,
fieldLabel: 'Label',
hideLabel: true,
editable: false,
format: 'H:i',
increment: 30,
submitFormat: 'H:i'
}
}




onCellEditingEdit: function(editor, e, eOpts) {

var id=editor.grid.getSelectionModel().getSelection()[0].get('id');

var value=e.value;
if(e.field=='time')
{
var timeval = new Date(value);
if(timeval!='Invalid Date')
value=Ext.util.Format.date(timeval,'H:i');
}


Ext.Ajax.request({
url : 'app/data/update.php' ,
params : { id:id,field:e.field,value:value },
method: 'GET',
success: function ( result, request ) {

var res=Ext.JSON.decode(result.responseText);

}




});


}

Gary Schlosberg
30 Mar 2014, 10:09 AM
Thanks for taking the time to share your solution with the community.