How to scroll to the end of the form in ExtJS

若如初见. 提交于 2020-01-05 05:34:07

问题


I have a form with autoScroll feature. How can I scroll to the bottom of the form when I add a new item to it?

 height: 200,
 autoScroll: true,

Here is my sample code


回答1:


If the field is added at the end of the form then the following solution might help:

EXTJS 5 & 6

http://docs.sencha.com/extjs/5.1.0/api/Ext.form.Panel.html#cfg-scrollable

In the form config:

scrollable: true,

In button handler:

{
                xtype: 'button',
                itemId: 'addChildBtn',
                disabled: false,
                text: 'Clone fieldset',
                 handler: function () {
                // Clone field set 
                  var set = Ext.getCmp('s1');         
                 var s = set.cloneConfig();
                form.add(s);
                this.up('form').getScrollable().scrollTo(0, 9999);
                }
            }

EXTJS 4

http://docs.sencha.com/extjs/4.1.3/#!/api/Ext.form.Panel-method-scrollBy

In button handler:

{
                xtype: 'button',
                itemId: 'addChildBtn',
                disabled: false,
                text: 'Clone fieldset',
                 handler: function () {
                // Clone field set 
                  var set = Ext.getCmp('s1');         
                 var s = set.cloneConfig();
                form.add(s);
                this.up('form').scrollBy(0, 9999, true);
                }
            }


来源:https://stackoverflow.com/questions/40672250/how-to-scroll-to-the-end-of-the-form-in-extjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!