PDA

View Full Version : [CLOSED] Adding controls to VBox layout causes scrolling to top



extnetuser
May 15, 2013, 8:59 AM
Hi,

i am experiencing a reset of the scroll position when both adding or removing controls to a scrollable panel having VBox layout. Is there a possibility to maintain the scroll position?


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>

@Html.X().ResourceManager()

@(Html.X().FormPanel()
.ID("MyFormPanel")
.Title("Panel Title")
.AutoScroll(true)
.MaxHeight(200)
.Layout(LayoutType.VBox)
.Items(
it =>
{
it.Add(Html.X().TextArea().Height(400));
it.Add(Html.X().Button().ID("TestButton").Text("Remove Me").OnClientClick("App.TestButton.destroy();"));
it.Add(Html.X().Button().Text("Add").OnClientClick("Ext.getCmp('MyFormPanel').add({width:50,xtype:'tex tfield'});"));
})
)

</body>
</html>

Greetings and thank you,
extnetuser

Daniil
May 15, 2013, 10:10 AM
Hi @extnetuser,

Thank you for a clear example.

This appears to be working for adding.

var panel = App.MyFormPanel,
scrollTopToRestore = panel.body.getScrollTop();

panel.add({ xtype: 'textfield' });
panel.body.setScrollTop(scrollTopToRestore);

I think it should work for removing as well.

extnetuser
May 15, 2013, 12:40 PM
Thank you kind Sir, you workaround works.

Thread can be marked as closed.