This is a migrated thread and some comments may be shown as answers.

Syncing Selected Tab In Child Templates

1 Answer 66 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 16 May 2017, 08:26 PM

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?

1 Answer, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 17 May 2017, 08:30 AM
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.
Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or