I am basically just trying to set the default group on a GridView but when I add the GroupDescriptorCollection the app throws a NullReferenceException. I am using a custom data object with defined properties and have also tried it with the DataGrid, same error both ways. How can I set the default grouping on a GridView?
Thanks!
Thanks!
4 Answers, 1 is accepted
0
Hi,
Vlad
the Telerik team
Have you checked "Grouping" category in our demos?
Regards,Vlad
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
jfkrueger
Top achievements
Rank 1
answered on 28 Nov 2011, 05:38 PM
Hello,
Thank you for the response. Yes, I have checked those demos which is where I got the code to do this in the first place (From the custom aggregates demo). Here is my grid...
<
telerik:RadGridView
x:Name
=
"RadGridViewStopLossDetails"
ItemsSource
=
"{Binding StopLossDetailsGridData}"
AutoGenerateColumns
=
"false"
ShowGroupPanel
=
"True"
FontSize
=
"9"
IsFilteringAllowed
=
"False"
ShowColumnFooters
=
"True"
ShowGroupFooters
=
"True"
Margin
=
"5,10,0,0"
Grid.Column
=
"0"
Grid.Row
=
"1"
VerticalAlignment
=
"Top"
RowIndicatorVisibility
=
"Collapsed"
AutoExpandGroups
=
"True"
Height
=
"Auto"
Width
=
"Auto"
HorizontalAlignment
=
"Center"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
Header
=
"Date Requested"
DataMemberBinding
=
"{Binding DateRequested}"
TextWrapping
=
"wrap"
IsVisible
=
"True"
UniqueName
=
"DateRequested"
>
<
telerik:GridViewDataColumn.Footer
>
<
TextBlock
Text
=
"Totals:"
/>
</
telerik:GridViewDataColumn.Footer
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
Header
=
"Amount Requested:"
DataMemberBinding
=
"{Binding AmountRequested}"
TextWrapping
=
"NoWrap"
DataFormatString
=
"c"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:SumFunction
SourceField
=
"AmountRequested"
ResultFormatString
=
"{}{0:c}"
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
Header
=
"Date Reimbursed"
DataMemberBinding
=
"{Binding DateReimbursed}"
TextWrapping
=
"NoWrap"
UniqueName
=
"DateReimbursed"
/>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
Header
=
"Amount Reimbursed"
DataMemberBinding
=
"{Binding AmountReimbursed}"
TextWrapping
=
"NoWrap"
DataFormatString
=
"c"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:SumFunction
SourceField
=
"AmountReimbursed"
ResultFormatString
=
"{}{0:c}"
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
</
telerik:GridViewDataColumn
>
<
telerik:GridViewDataColumn
IsReadOnly
=
"True"
Header
=
"% Reimbursed"
DataMemberBinding
=
"{Binding PercentReimbursed}"
TextWrapping
=
"NoWrap"
DataFormatString
=
"{}{0:0%}"
>
<
telerik:GridViewDataColumn.AggregateFunctions
>
<
telerik:SumFunction
SourceField
=
"PercentReimbursed"
ResultFormatString
=
"{}{0:0%}"
/>
</
telerik:GridViewDataColumn.AggregateFunctions
>
</
telerik:GridViewDataColumn
>
</
telerik:RadGridView.Columns
>
<
telerik:RadGridView.GroupDescriptors
>
<
telerik:ColumnGroupDescriptor
Column
=
"{Binding Columns[\DateRequested\], ElementName=RadGridViewStopLossDetails}"
SortDirection
=
"Ascending"
/>
</
telerik:RadGridView.GroupDescriptors
>
</
telerik:RadGridView
>
0
Hi Jfkrueger,
I've tried to reproduce the problem using the xaml provided and it works fine on my end. You can find my test application attached. Can you give it a try and modify it in order to demonstrate the problem?
All the best,
Yordanka
the Telerik team
I've tried to reproduce the problem using the xaml provided and it works fine on my end. You can find my test application attached. Can you give it a try and modify it in order to demonstrate the problem?
All the best,
Yordanka
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Hi jfkrueger !
I don't know if you already solve your issue, i had this same problem once, I always get the NullReference error when the Grid Loads
The problem in my case are caused by a little mistake, the two columns that i'm using in the GroupDescriptor are binding to properties, but the Name of the properties in XAML are wrong. Because of that the Grid try to group the columns but it just can't because their are null, so theres nothing to group!
So, when i fix the Binding of the columns all works again perfectly.
I hope that help you.
I don't know if you already solve your issue, i had this same problem once, I always get the NullReference error when the Grid Loads
The problem in my case are caused by a little mistake, the two columns that i'm using in the GroupDescriptor are binding to properties, but the Name of the properties in XAML are wrong. Because of that the Grid try to group the columns but it just can't because their are null, so theres nothing to group!
So, when i fix the Binding of the columns all works again perfectly.
I hope that help you.