Syncing Selected Tab In Child Templates

2 posts, 0 answers
  1. David
    David  avatar
    5 posts
    Member since:
    Nov 2010

    Posted 16 May 2017 Link to this post

    How would I sync the child template ItemSelected with every child RadPageViewStripElement?

    In other words, if I have a grid with 22 rows and each row is expandable, when the user changes a tab of a nested child template, how would I also change the other child templates (that are expanded) to that same tab?

  2. Dimitar
    Admin
    Dimitar avatar
    2831 posts

    Posted 17 May 2017 Link to this post

    Hi David,

    You can use the ViewCellFormatting event to change the selected page of all expanded views:
    int selectedindex = -1;
    int prevIndex = -1;
    private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
    {
        GridDetailViewCellElement detailCell = e.CellElement as GridDetailViewCellElement;
        if (detailCell != null)
        {
            var pageView = detailCell.PageViewElement as RadPageViewStripElement;
            pageView.ItemSelected -= PageView_ItemSelected;
            pageView.ItemSelected += PageView_ItemSelected;
     
            if (selectedindex != -1 && pageView.Items.IndexOf(pageView.SelectedItem) != selectedindex)
            {
                pageView.SelectedItem = pageView.Items[selectedindex];
            }
     
        }
    }
     
    private void PageView_ItemSelected(object sender, RadPageViewItemSelectedEventArgs e)
    {
        var pageView = sender as RadPageViewStripElement;
        selectedindex = pageView.Items.IndexOf(e.SelectedItem);
     
        if (prevIndex != selectedindex)
        {
            this.radGridView1.TableElement.Update(GridUINotifyAction.StateChanged);
        }
     
        prevIndex = selectedindex;
    }

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top