[Ext JS] 7.25.1 Form or panel is automatically positioned to the wrong input box

Form has many input boxes, usually set up vertical scroll bars. In this state, when submitting the form, if the input values ​​of some fields are illegal, and these fields are not in the directly displayed page, clicking the submit button does not seem to have any effect.
The ideal effect is that if any field input is illegal, the scroll bar can automatically scroll to the illegal field, as shown below:
insert image description here

Realization program exploration

How to achieve the above effect? After checking the related methods of Ext.form.Panel, I found the position where the scroll bar scrollTo ( x, y, [animate] ) can be set. This method has three parameters, the first two are the x and y coordinates, and the third is an optional parameter that sets whether the setting has an animation effect.
So I thought: Is it okay to set the scroll bar with the coordinate setting of the illegal field as a parameter? The code is similar:

form.scrollTo(fields[i].getPosition()[0],fields[i].getPosition()[1],true);

The above is valid when the scroll bar is not scrolling at all, but after the scroll bar is scrolled, the above method is invalid. why?
The reason is that after the scroll bar is scrolled, the coordinates corresponding to each field will change, and the amount of this change is the amount of the scroll bar. Here is mainly the ordinate, that isformPanel.getScrollY()

Guess you like

Origin blog.csdn.net/oscar999/article/details/124329927