PDA

View Full Version : grid editor value problem



nicobarten
14 Jan 2010, 1:28 AM
Hi,

I have a little problem with my grid.

I have a datastore, with the following fields:

* hour_id
* from
* to

Now, in the grid, i also display another column named 'total'. In 'total' it must show the total hours worked, based on 'from' and 'to', so 'to' minus (-) 'from'.

I did this using the renderer property of the column, and because it needs a dataIndex i used as dataIndex 'hour_id' (i don't use it, but i need something right?).

So in my renderer function i have something like this:



var from = record.data.from;
var to = record.data.to;

return calc_time_diff(from, to).substring(0, 5);


This works for the rendering of the grid. However, i also have an editor (with RowEditor plugin) implemented. So for the editor parameter i just have this:



xtype: 'textfield',
disabled: true


Disabled because the user may not change the value, but it don't affect the value. Anyway, my problem is this:

Because of the dataIndex set on hour_id, and the renderer function only works for the display and not for the editor mode, it shows when editing the hour_id, and not the last known time value based on 'to' and 'from'.

How to do this?

Condor
14 Jan 2010, 1:46 AM
RowEditor is a bit inflexible on that subject.

The easiest solution is probably to use a calculated field (http://www.extjs.com/forum/showthread.php?t=28826) to create a real 'total' field.

nicobarten
14 Jan 2010, 2:56 AM
Werkt geweldig, dank je wel! :D