Maintaining scroll position of page

6 posts, 0 answers
  1. Avinash
    Avinash avatar
    3 posts
    Member since:
    Oct 2012

    Posted 27 Sep 2010 Link to this post

    Hi,
    I am using rad tree view within asp.net page. In page i have set the MaintainScrollPositionOnPostback="true". But when i expand the tree, scroll position goes to expanded item. I want my page's scroll position to remain same. Let me know how can i fix this.

    Thanks,
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 30 Sep 2010 Link to this post

    Hi Avinash,

    Well, MaintainScrollPositionOnPostback is used in situations you actually want to persist position regarding last action. For example, you scroll down the tree and edit it's last item, but as it happens the handler of the NodeEdit event is on the server and the page postbacks. Without MaintainScrollPositionOnPostback set to true, the page will have the default scroll position.

    A solution to your problem would be either:
    1. to stop MaintainScrollPositionOnPostback;
    2. if you need non-default scrollPosition, you can persist the position in cookie and on pageLoad (or even better on ClientLoad event of the TreeView) to restore it.

    Hope this is helpful for you!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ayush
    Ayush avatar
    3 posts
    Member since:
    Dec 2013

    Posted 02 Jan 2014 Link to this post

    Hello,

    Am using Rad Tree view and everything works fine but am facing problem in expand and collapse.
    Whenever the page loads the treeview automatically collapse so the user is confused ?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jan 2014 Link to this post

    Hi Ayush,

    I guess that you are Expanding the RadTreeNode from server side. Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadTreeView ID="RadTreeView1" runat="server">
        <Nodes>
            <telerik:RadTreeNode Text="Node1" runat="server">
                <Nodes>
                    <telerik:RadTreeNode Text="Node1.1" runat="server">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node1.2" runat="server">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node1.3" runat="server">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
            <telerik:RadTreeNode Text="Node2" runat="server">
                <Nodes>
                    <telerik:RadTreeNode Text="Node2.1" runat="server">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node2.2" runat="server">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node2.3" runat="server">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadTreeNode node = RadTreeView1.FindNodeByText("Node1");
        node.Expanded = true;
    }

    Please elaborate your requirement if it doesn't help.
    Thanks,
    Shinu.
  6. Ayush
    Ayush avatar
    3 posts
    Member since:
    Dec 2013

    Posted 02 Jan 2014 Link to this post

    Hello Shinu,

    In my case the data is coming from database I have not created any node in designer page.

    Thanks,
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 02 Jan 2014 Link to this post

    Hi Ayush,

    Please have a look into the following code snippet which works as expected for me.

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Details", ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
        DataTable data = new DataTable();
        adapter.Fill(data);      
        RadTreeView1.DataSource = data;
        RadTreeView1.DataTextField = "text";
        RadTreeView1.DataFieldParentID = "parentid";
        RadTreeView1.DataFieldID = "id";
        RadTreeView1.DataBind();
        RadTreeNode node = RadTreeView1.FindNodeByText("Politics");
        node.Expanded = true;
    }

    Let me know if you have any concern.
    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017