PDA

View Full Version : Questions about focus.



robertoroberto
22 Aug 2009, 11:23 PM
Hi
I need to set focus on the first editable field of a panel.
There is already available a function to do it ?
Panel can be build with TabPanel, so the function should automtically switch also on the tab where
the first editable field is located.
I haven't the name of it... so the function should discover it.
I have another case: I have a list of fields.
I must mark all fields as invalid and also set focus on the first editable field (also here it can be in a tab and so I should switch to it).
E.g.
I have field A, B, C, D, E
My panel contains field in this order : K, T, D, A, M, N, C, B, E, Y, Z
So the field with focus must be "D". If "D" is a tab, I should switch on it
This second case is related to display server side error messages.
A field can be part of "n" errors. It is possible to invoke "n" times the markInvalid function but collect all messages?
I try it.. but always the latest message is displayed. I should override the markInvalid function?
I try to simply invoke the markInvalid and/or focus on a field in a non active tab (tab 0) but it is not automatically switched.
Of course I can write a function to do it (after render I believe), but I don't want to reinvent the wheel

Any idea ?
ty

Animal
22 Aug 2009, 11:38 PM
That's a very confusing lump of text you posted.

What do you need? Simply. One requirement at a time.

robertoroberto
23 Aug 2009, 12:29 AM
I'm sorry for the text....

1) I need to set focus on a field. I know only the name (id).
If this field is on a tab. I should switch to that tab.

2) I have a list of field id (not ordered).
I should know the "display" order fields because I must set the focus on the First (editable) field.

Animal
23 Aug 2009, 12:33 AM
OK,

1. You need to access the field you want to focus. Then use findParentBy to find the parentContainer who's parent is a TabPanel. Add a {single: true} activate listener to it which focuses the field. Then activate it.

2. Again, I don't understand what you said.

Condor
23 Aug 2009, 12:33 AM
1. Ext has no standard function for this, but you can build one yourself (go up the ownerCt tree and check if the child is visible in the layout).

2. The 'display' order is the order in the ownerCt items collection. Use the field with the lowest indexOf value.

robertoroberto
23 Aug 2009, 2:05 AM
Ty to all

1) Ok. I will try it

2) I will try it.. but it is not so simple...
With complex panel (with nested panel.. maybe using column layout and so on...) it is not simple to use directly the indexOf...