PDA

View Full Version : Several questions ...



rapisthesolution
2 Aug 2009, 11:06 PM
Hi,

it's me again.
I have several questions and I didn't find the answers on my own.

I have a function in the 'afteredit' event of a editorgrid. The function should track me the edit of a specific field "field 1" and do some stuff with it.

1. Question:
I don't understand the parameters of the function. Is there a guide which parameters can be delivered by the afterEdit event and other functions?

2. Question:
I want to do some stuff with the specific field. "field 1" is a timeField and i want to set
another minValue and maxValue for it. How can i get the field there and change its
properties?



mygrid.on({
afterEdit: function(grid, row, field, rowIndex, columnIndex) {
if (grid.field == 'field 1') {
alert('ok');
}

}
});

Condor
2 Aug 2009, 11:28 PM
1. The event is called afteredit (small e). If you want to know the parameters of the event you should look at the API docs for afteredit (http://extjs.com/deploy/dev/docs/?class=Ext.grid.EditorGridPanel&member=afteredit).

2. Don't you want to change the minValue and maxValue properties in the beforeedit event? Unfortunately, TimeField is missing setMinTime and setMaxTime method (see here (http://extjs.com/forum/showthread.php?t=75982) for fix).

rapisthesolution
3 Aug 2009, 12:33 AM
Thx for your answer!

Could you give me a tip how to get the specific field I want to make the changes to?

danh2000
3 Aug 2009, 12:42 AM
Didn't you follow the link?

From the API docs for afteredit:


Fires after a cell is edited. The edit event object has the following properties

* grid - This grid
* record - The record being edited
* field - The field name being edited
* value - The value being set
* originalValue - The original value for the field, before the edit.
* row - The grid row index
* column - The grid column index

Condor
3 Aug 2009, 1:20 AM
So you are looking for:

beforeedit: function(e){
if(e.field == 'mytimefield'){
var f = e.grid.getColumnModel().getCellEditor(e.column, e.row).field;
f.setMinTime(...);
f.setMaxTime(...);
}
}

rapisthesolution
3 Aug 2009, 1:26 AM
Exactly! Thank you!

It's pretty hard for me to find the right code lines to do something like "e.grid.getColumnModel().getCellEditor(e.column, e.row).field".

Can you say me how I can figure out such things on my own?

I'm using firebug for debugging.

Condor
3 Aug 2009, 2:54 AM
You would use the API docs:
- First you find which parameters a passed by the beforeedit event.
- Next, you want to find the editor that you specified in the column model.
- So you start with the grid (EditorGridPanel) and look for the method to get the column model (getColumnModel).
- Next, in the ColumnModel you find the method to get the editor (getCellEditor).
- In the getCellEditor docs you see that it doesn't return an Ext.form.Field which you specified in the column model config, but an Ext.Editor.
- In the Ext.Editor docs you can find that the actual Ext.form.Field can be retrieved using the field property.