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

[Solved] Using DataPager with a Child Grid

1 Answer 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Paulie
Top achievements
Rank 1
Paulie asked on 01 Feb 2010, 03:39 PM
I'm using the RadGridView with a DataPager on a Parent Grid and it works fine.  For each row in the ParentGrid, I'm defining a RowDetailsTemplate to have a child binded grid.  This also works fine, but I can't use the DataPager with the inner child grid.  The reason seem obvious to me, but the solution is not.  I think the problem is that I can not name the child grid using x:name, because then the child grid for each row will have the same name, causing an error.  If I can't name the child grid, how do I link the data pager?

Is there a way to link a RadGridView with a DataPager, without assigning a specific x:name to the RadGridView and DataPager: Element?

Or perhaps Is there a way to assign a x:name to the RadGridView at runtime, and also link it to the DataPager:Element at runtime? In this case I would name each Rows ChildGrid as ChildGrid0, ChildGrid1, ChildGrid2, etc... assuring that each child grid had a unique name.  I'm originally from the Jsp/Java world and this kind of name iteration at runtime is quite easy.  It's perhaps the only thing so far that is easier in Jsp. 

Here is a sampe mock-up of the code.  My actual code has a bit more detail, but I stripped it down for the purpose of this example:

<telerikGridView:RadGridView x:Name="ParentGrid" AutoGenerateColumns="True">
    <telerikGridView:RadGridView.RowDetailsTemplate>
        <DataTemplate>
            <StackPanel>
                <telerikGridView:RadGridView x:Name="ChildGrid" ItemsSource="{Binding ActualTerms}" AutoGenerateColumns="True"/>
                <data:DataPager Source="{Binding ItemsSource, ElementName=ChildGrid}" PageSize="4"></data:DataPager>
          </StackPanel>
        </DataTemplate>
    </telerikGridView:RadGridView.RowDetailsTemplate>
</telerikGridView:RadGridView>
<data:DataPager Source="{Binding ItemsSource, ElementName=ParentGrid}" PageSize="4"></data:DataPager>

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 02 Feb 2010, 12:44 PM
Hi Paul Russo,

You can simply create a new user control with a grid and a pager inside it. This user control will be a standalone unit and you can have any names and logic inside it. You can even reuse it if in another place if you want to.

Not to mention that a DataPager does not need to know the name of the grid. It simply needs to have its Source defined. In this way you can have one DataPager that commands 100 grids, listboxes, you name it.

Place this user control inside the row details template. I have prepared a sample project that does that. This is the sample project from my blog post, but I have added a DataPager inside the row details control. The class is called AlbumsControl.

I hope this helps.

All the best,
Ross
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Paulie
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Share this question
or