Gridview "empty content" error when using TabControl.

1 Answer 27 Views
GridView TabControl
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Bronze
Psyduck asked on 26 Aug 2021, 07:07 AM

Hello.

 

I posted a post a while ago and had the desired solution.

https://www.telerik.com/forums/error-empty-gridview-message-content-in-gridview-sdk

 

However, in this case, there was only one grid view in the tab control and the other items were of different types.

Now I need multiple gridviews inside the tab control.

If you add multiple gridviews, an error like the link above will occur.

The first gridview passes, but errors start in the remaining 2nd and 3rd gridviews.

 

The attached example is just adding TabItems from the previous link and deferring InsertAdditionalContentControl .

How to solve this?

 

Thanks.

1 Answer, 1 is accepted

Sort by
1
Accepted
Martin Ivanov
Telerik team
answered on 30 Aug 2021, 11:43 AM

Hello KIM,

This happens because the RadGridView controls in the second and third tabs are not loaded in the visual tree until you select the corresponding tab. In order to resolve this, you can include two additional if-conditions and move the code that unsubscribes from the Loaded event in the InsertAdditionalContentControl. Here is the modified version of the custom behavior:

private void OnGridViewLoaded(object sender, RoutedEventArgs e)
{
	this.gridView.Dispatcher.BeginInvoke(new System.Action(() => {
		this.InsertAdditionalContentControl();
	}));       
}

private void InsertAdditionalContentControl()
{
	if (this.additionalContentControl.Content != this.messageContent)
	{
		this.additionalContentControl.Content = this.messageContent;
	}

	var rootGrid = this.gridView.FindChildByType<Grid>();
	if (rootGrid != null && !rootGrid.Children.Contains(this.additionalContentControl))
	{
		rootGrid.Children.Add(this.additionalContentControl);
		this.gridView.Loaded -= OnGridViewLoaded;
	}
}

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView TabControl
Asked by
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Bronze
Answers by
Martin Ivanov
Telerik team
Share this question
or