I have a GridView where I am using Self-referencing feature to group rows by some property (http://www.telerik.com/help/silverlight/gridview-self-referencing-grid.html).
It is working as expected. I just want to show count of items under each group. For example currently I have:
+ parentRow1
- parentRow2
childRow1
childRow2
What I want is to show count of child rows next to the +/- sign, like that:
+ (7) parentRow1
- (2) parentRow2
childRow1
childRow2
Is this possible? I can see there are groups aggregates that will do similar thing (http://www.telerik.com/help/silverlight/gridview-grouping-aggregates.html) but it is not quite what I am looking for.
Thanks,
Nick
8 Answers, 1 is accepted
The link you provided concerns creating a Self-Reference hierarchy, but it aims at organizing your RadGridView in a hierarchy. Furthermore, RadGridView does provide the functionality of Grouping it according to a particular property. So, which structure do you point at - grouping or hierarchy.
However, if you want to predefine the GroupRow, you may predefine the GroupHeaderTemplate of the grid:
<telerik:RadGridView Name="clubsGrid"                     ItemsSource="{Binding Clubs}">        <telerik:RadGridView.GroupHeaderTemplate>            <DataTemplate>                <TextBlock Text="{Binding Group.Key}" />            </DataTemplate>        </telerik:RadGridView.GroupHeaderTemplate></telerik:RadGridView>Greetings,
Maya
the Telerik team
Thanks for your reply.
I understand that RadGridView provide the functionality of grouping but I was talking exactly about self-referenced hierarchy.
So as I said in original post, I have a grid view where I am "organizing" it in a hierarchy by using Self-Reference hierarchy. I would like to keep it as is but I now have a need to add a number of collapsed (or you can say "organized" or "grouped") rows (in child grid) next to the + sigh that appears when you are using self-reference feature. Using of grouping is not an option for me so I was wondering if it is achievable as is?
I am attaching an image (original "before state" was taken from your site here) that describes what I want to achieve.
Thanks,
Nick
You need to predefine the RowStyle of the RadGridView. I am sending you a sample project providing you with its code. You may changed it in the way you want - for example you may define a TextBlock inside and bind its Text property to the result of the aggregate function - Count.
Maya
the Telerik team
Thanks for the sample, however it is not really answering my question.
Where should I specify Aggregate function? Could you please provide an example that will explain your statement?
Thanks,
Nick
I am sending you an updated version of the sample project. Depending on your exact requirements, you may define a particular value in the Text of the TextBlock (in the place of the "20").
Maya
the Telerik team
I am sorry if I was not clear in my question and my requirements :)
So, I know how to change the control template (example you sent me last time just added <Text Block Text="Blah"/> to toggle button template) What I don't know is how to use Group aggregate you suggested me to use in order to show child table row counts when the grid is self referenced. I personally don't see how that is achievable and that is why I need your help. I am ok with adding TextBlock or anything else for that matter to the template, what I don't understand is how to bind it to results of some aggregate and how aggregate will work (as I see it is working with group descriptors, here we don't have it)
My requirements are very straight forward and I already mentioned them couple of times: Given self referenced grid view I need to show count of the rows of child table next to + toggle button sign. That is it.
You can see my exact requirements of what I want to see on the image I attached couple replies back. I am attaching it again for your convenience. Left side of the image is what it currently is and right side of the image is what I need to have.
I highlighted numbers that I need to show in red rectangles, so they are clear to see. For example, first row has 3 next to toggle button. You can see that this row is expanded and there are 3 rows in the child table and that is why there is 3 next to toggle button.
Could you please give me a solid example that will show how can I achieve the result like on the image I attached. If there are any other sources of information you can suggest me to look at, I would really appreciate that.
Thanks,
Nick
I am sending you a sample project demonstrating how to achieve the behavior you require. In this case no aggregate function is used. Instead a new property holding the number of child elements is added and it is bound to the TextBlock in the first column. The sample project is based on the example in our demo.
 
Maya
the Telerik team