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

Change Grouping Header and Expand A Group?

2 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Temp
Top achievements
Rank 1
Temp asked on 15 Apr 2010, 05:17 AM
Hi I am building an 8020 financial report, and displaying customers in a grid. The data we are getting has a boolean called Top80 which depicts if the customer was in the top 80% of revenue contributors.

I have a group on this and it works fine, what I want though is the header for the false one to say "Bottom 20%" and the true one to say "Top 80%", instead of True and False. Can I do this? Seems like an easy thing?

Also can I expand the group for True after it has been databound, so the top80 is expanded and bottom 80 is collapsed?

Thank you.

My code is as follows:

 

void reportingservices_GetCustomerTurnoverCompleted(object sender, reportingservices.GetCustomerTurnoverCompletedEventArgs e)  
        {  
            _CustomerTurnoverData = e;  
            RadGrid8020.GroupDescriptors.Add(new GroupDescriptor(){Member="Top80", SortDirection = System.ComponentModel.ListSortDirection.Ascending, DisplayContent="Top 80"});  
            RadGrid8020.ItemsSource = _CustomerTurnoverData.Result;  
            RadGrid8020.Grouped += new EventHandler<GridViewGroupedEventArgs>(RadGrid8020_Grouped);  
        }  
          
        void RadGrid8020_Grouped(object sender, GridViewGroupedEventArgs e)  
        {  
            //Need to do something here to open the group?  
        } 

<telerikGridView:RadGridView   
                    x:Name="RadGrid8020"   
                    MinWidth="400" MaxWidth="900" 
                    ShowGroupPanel="false"   
                    CanUserDeleteRows="false"     
                    CanUserFreezeColumns="false" 
                    CanUserInsertRows="false" 
                    CanUserReorderColumns="true" 
                    CanUserResizeColumns="false" 
                    CanUserSelect="true" 
                    CanUserSortColumns="true" 
                    IsReadOnly="true" 
                    AutoGenerateColumns="false" ScrollMode="RealTime" 
                >     
                <telerikGridView:RadGridView.SortDescriptors> 
                    <telerikData:SortDescriptor Member="Rank" SortDirection="Ascending" /> 
                </telerikGridView:RadGridView.SortDescriptors> 
                  
                <telerikGridView:RadGridView.Columns> 
                    <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Rank}" Header="Rank" IsFilterable="false" IsSortable="true" /> 
                    <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding CustomerName}" Header="Client" HeaderTextAlignment="Left" IsFilterable="false" IsSortable="true" TextAlignment="Left" /> 
                    <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding JobCount}" Header="Job Count" HeaderTextAlignment="Right" IsFilterable="false" IsSortable="true" TextAlignment="Right" DataFormatString="{}{0:n0}" /> 
                    <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding Turnover}" Header="Turnover" HeaderTextAlignment="Right" IsFilterable="false" IsSortable="true" TextAlignment="Right" DataFormatString="{}{0:c2}" /> 
                    <telerikGridView:GridViewDataColumn DataMemberBinding="{Binding AverageJobTurnover}" Header="Avg Per Job" HeaderTextAlignment="Right" IsFilterable="false" TextAlignment="Right" DataFormatString="{}{0:c2}" /> 
                </telerikGridView:RadGridView.Columns> 
            </telerikGridView:RadGridView> 

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 15 Apr 2010, 07:13 AM
Hello,

You can use GroupHeaderTemplate similar to our example and you can use Loaded event of the control placed in this template to choose if this group should be expanded or not - example with TextBlock Loaded:

var groupRow = ((TextBlock)sender).ParentOfType<GridViewGroupRow>();
groupRow.IsExpanded = ...

All the best,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Temp
Top achievements
Rank 1
answered on 16 Apr 2010, 05:33 AM
Thank you that was very helpful.
Tags
GridView
Asked by
Temp
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Temp
Top achievements
Rank 1
Share this question
or