PDA

View Full Version : Problems with timefield in grid



Caeruleus
29 Jan 2010, 7:33 AM
Hi folks,

I've created a little webapp in which you can enter amount of hours worked for each day of the week, and then later create reports of that. Everything seemed to work fine, but then today I ran into a very interesting problem, which I'll try to explain with this image.

http://img.photobucket.com/albums/v27/Lupiandry/timefield_bug.png

To create the problem, I follow these steps:

1) Select a row to enter (or edit, regardless)
2) Enter a value over 9:45 (either by keyboard, or select from the dropdown)
3) Save this (see the red icons)
4) Refresh page and edit the same line again, but this time pick another timefield
5) Save this (notice the red icons!)
6) Refresh page: the value over 9:45 is gone because the server is assuming the cell is empty (value is not send, therefor null).

This seems to be coming from somewhere inside my extjs code, since the grid isn't even marking the cell while it does mark all the others. If the cell value is below 9:45 it will work perfectly and not be 'forgotten'.

I did a lot of searching on the forum and google, but I can't find anyone with the same problem so I'm assuming it's somewhere in my code? Perhaps I'm missing a setting somewhere...

This is the relevant code (shortend to keep readable, only took out extra columns and styles) to create the fields, the grid and the datastore:


CCDataStore = new Ext.data.Store({
id: 'CCDataStore',
proxy: new Ext.data.HttpProxy({
url: url,
method: 'POST'
}),
baseParams:{task: "LISTING", id_workletter: id_workletter},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'id', type: 'int', mapping: 'id'},
// hours
{name: 'monday', type: 'string', mapping: '1'},
{name: 'tuesday', type: 'string', mapping: '2'},
{name: 'wednesday', type: 'string', mapping: '3'}
{name: 'sum', type: 'string', mapping: 'sum'}
]),
writer : new Ext.data.JsonWriter(),
sortInfo:{field: 'sum', direction: "ASC"},
autoSave: true,
autoLoad: false
});

CCColumnModel = new Ext.grid.ColumnModel({
columns: [{
header: 'Maandag',
dataIndex: 'monday',
editor: new Ext.form.TimeField({
increment: 15
})
},{
header: 'Dinsdag',
dataIndex: 'tuesday',
editor: new Ext.form.TimeField({
increment: 15
})
},{
header: 'Woensdag',
dataIndex: 'wednesday',
editor: new Ext.form.TimeField({
increment: 15
})
}],
defaults: {
sortable: true,
menuDisabled: false,
width: 50}
});

editor = new Ext.ux.grid.RowEditor({
saveText: 'Opslaan',
errorSummary: false,
listeners: {
beforeedit: function(roweditor, rowIndex){
var record = CCDataStore.getAt(rowIndex);
if ((record.id == 0) || (record.id == 1))
{
return false;
}else
{
return true;
}
}
}
});

CCListingGrid = new Ext.grid.GridPanel({
id: 'CCListingGrid',
store: CCDataStore,
cm: CCColumnModel,
enableColLock:true,
sm: new Ext.grid.RowSelectionModel({singleSelect:false}),

title: title,
xtype: 'grid',
autoWidth: true,
flex: 2,
plugins : editor,
tbar : toolbar,
bbar: new Ext.PagingToolbar({
pageSize: 200,
store: CCDataStore,
displayInfo: true
}),
view: new Ext.grid.GridView({
forceFit: true,
emptyText: 'Geen resultaten gevonden',
})
});


After defining it, everything is loaded and placed just fine. No errors, just this very interesting problem. I'm really hoping someone here could help me solve it. :)

Thanks in advance,
Caeruleus