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

Removing and adding a MultiPage for a tab

1 Answer 27 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Felix
Top achievements
Rank 1
Felix asked on 24 Jan 2017, 03:27 PM

Hey!

I want to remove the PageView of a tab and give the tab a new PageView. Currently I'm doing it like this:

// Delete PageView from tab
RadTab tabToReset = TabStripBookings.FindTab(t => Convert.ToInt32(t.Attributes["bookingId"]) == bookingId);
 
if (tabToReset == null)
{
    System.Diagnostics.Debug.WriteLine($"Tab with booking id {bookingId} not found.");
    return;
}
 
// Remove old PageView
MultiPageBookings.PageViews.Remove(tabToReset.PageView);
 
// Add new PageView to tab
AddPageView(tabToReset);

 

The "AddPageView" Method looks like this:

RadPageView pageView = new RadPageView();
pageView.ID = "PageView_" + tab.Attributes["bookingId"] ;      // set the id of the pageview depending on the booking ID (0 for new booking)
pageView.CssClass = "contentWrapper" + tab.Index;
pageView.Attributes.Add("bookingId", tab.Attributes["bookingId"]);
pageView.Attributes.Add("day", tab.Attributes["day"]);
tab.PageViewID = pageView.ID;
MultiPageBookings.PageViews.Add(pageView);

 

And finally my PageViewCreated Event:

BookingControl userControl = (BookingControl) Page.LoadControl("BookingControl.ascx");
 
// PageView ID is: PageView_BookingId -> split in PageView & BookingId
// Set UserControl id to UserControl_BookingId
userControl.ID = "UserControl_" + e.PageView.ID.ToString().Split('_')[1];
userControl.BookingDeleted += UserControl_BookingDeleted;       // Subscribe to event when a booking is deleted
userControl.FormReset += UserControl_FormReset;                 // Subscribe to event when the form shall be reseted
 
if (e.PageView.HasAttributes)
{
    userControl.ValuesSet = true;
    userControl.BookingId = Convert.ToInt32(e.PageView.Attributes["bookingId"]);
    userControl.SelectedDay = DateTime.ParseExact(e.PageView.Attributes["day"], "dd.MM.yyyy", null);
}
 
e.PageView.Controls.Add(userControl);

 

How it shall work:

The first method is called via an event. The MultiPage should be removed and a new one (basically the same one as before, but freshly initialized from the database) is added to the MultiPage.

What it actually does:

At first I don't see the new Tab where it should be. Instead the content of the next tab is shown, but when I switch to another tab and then switch back, the correct PageView is shown.

 

Is there any solution for this problem? Am I missing something? Can I maybe tell the TabStrip to reload its PageView?

Greetings

Felix

1 Answer, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 27 Jan 2017, 12:39 PM
Hello Felix,

Would you please check if selecting the newly created PageView after adding it to the MultiPage solves the issue? The selection could be achieved by setting the Selected property of the PageView to true.

Regards,
Peter Milchev
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
TabStrip
Asked by
Felix
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or