Welcome to the Xceed Community Sign in | Join | Help
Community Search  

Custom Group Header

Sort Posts: Previous Next
  •  05-08-2008, 3:01 PM Post no. 12107

    Custom Group Header

    Ok, so I have a list of Person objects in my datagridcontrol.

    I want to group by PersonTypeID(because sorting by an integer is MUCH faster than sorting by a string) but I want to display the associated  PersonTypeName inside the group header.

     

    Is there any way to accomplish this?

     

    Thanks so much for the help 

  •  05-09-2008, 3:17 PM Post no. 12136 in reply to 12107

    Re: Custom Group Header

    You can set the Column.Title property to display the PersonTypeName.

    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-13-2008, 10:17 AM Post no. 12215 in reply to 12136

    Re: Custom Group Header

    I don't think I explained my problem well enough.

     

    I have a datatable.  Each row has the following columns

    [PersonID] [PersonName] [PersonTypeID] [PersonTypeName] 

     

    So when I group by PersonTypeID, It shows the PersonTypeID inside the group description

    But I want to display the PersonTypeName inside the group description (but I don't want the grouping to use the PersonTypeName to filter, because it takes much longer to filter a string than an integer)


     

     

  •  05-13-2008, 5:29 PM Post no. 12226 in reply to 12215

    Re: Custom Group Header

    The default text display in the GroupHeaderControl is a combination of both the column's Title/TitleTemplate and GroupValueTemplate. That said, the Changing the group-header text example in the documentation demonstrates how this can be done.

    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 8:17 AM Post no. 12242 in reply to 12226

    Re: Custom Group Header

    Yes I already tried that.

    The GroupHeaderControl's DataContext is a GroupDescription object which only has a Title and Value.

    The GroupDescription's Value in my case is the PersonTypeID, so I have no way to get to the associated PersonTypeName of the PersonTypeID.

    It doesn't show a way to do this in the documentation. 

     

  •  05-14-2008, 9:03 AM Post no. 12245 in reply to 12242

    Re: Custom Group Header

    How  about something like this:

    <DataTemplate DataType="{x:Type xcdg:Group}">
      
    <StackPanel Orientation="Horizontal">
         
    <TextBlock Text="{Binding Path=Items[0][FirstName]}" />
         
    <TextBlock Text=" " />
         
    <TextBlock Text="{Binding Path=Items[0][LastName]}" />
      
    </StackPanel>
    </DataTemplate>

    If we assume that you are grouped by EmployeeID, then you could simply check the FirstName and LastName properties of the first item. 

     


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 9:41 AM Post no. 12248 in reply to 12245

    Re: Custom Group Header

    Genius! 

    But one problem, it doesn't work implicitly setting the template like that(I have had similiar problems implicitly setting other templates on the DataGridControl).  And even if it did, I don't want ALL the groups to have that template, I only want the specific column to have that group template.

    How in the world do I get to the Group object - so I can set it's template explicitly?  The DataGridControl only has a GroupLevelDescriptions collection. 

     

    Thanks so much for the help! 

  •  05-14-2008, 10:27 AM Post no. 12254 in reply to 12248

    Re: Custom Group Header

    Try this:

    <xcdg:DataGridControl x:Name="OrdersGrid"
                        ItemsSource="{Binding Source={StaticResource cvs_orders}}">
     <xcdg:DataGridControl.Columns>
        <xcdg:Column FieldName="EmployeeID"
                     TitleTemplate="{x:Null}"
                     GroupValueTemplate="{x:Null}">
           <xcdg:Column.GroupConfiguration>
              <xcdg:GroupConfiguration UseDefaultHeadersFooters="False">
                 <xcdg:GroupConfiguration.Headers>
                    <DataTemplate>
                       <xcdg:GroupHeaderControl>
                          <xcdg:GroupHeaderControl.Resources>
                             <DataTemplate DataType="{x:Type xcdg:Group}">
                                <StackPanel Orientation="Horizontal">
                                   <TextBlock Text="{Binding Path=Items[0][FirstName]}" />
                                   <TextBlock Text=" " />
                                   <TextBlock Text="{Binding Path=Items[0][LastName]}" />
                                </StackPanel>
                             </DataTemplate>
                          </xcdg:GroupHeaderControl.Resources>
                       </xcdg:GroupHeaderControl>
                    </DataTemplate>
                 </xcdg:GroupConfiguration.Headers>
              </xcdg:GroupConfiguration>
           </xcdg:Column.GroupConfiguration>
        </xcdg:Column>
     </xcdg:DataGridControl.Columns>
    </xcdg:DataGridControl>


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 10:43 AM Post no. 12256 in reply to 12254

    Re: Custom Group Header

    That works great!!!!   But when I minimize the groups, they disappear LOL!

    So if they are 4 different possible employeeIDs, as I minimize each one, it just disappears. 

    So it only shows 3 different possible employeeIDs after I minimize one of the group headers. 

     

    Thanks again for the help! 

  •  05-14-2008, 10:52 AM Post no. 12257 in reply to 12256

    Re: Custom Group Header

    oops! You need to wrap the DataTemplate in a GroupHeaderFooterItemTemplate whose VisibleWhenCollapsed property is set to true Smile

    <xcdg:Column.GroupConfiguration>
      <xcdg:GroupConfiguration UseDefaultHeadersFooters="False">
         <xcdg:GroupConfiguration.Headers>
            <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed="True">
               <DataTemplate>
                  <xcdg:GroupHeaderControl>
                     <xcdg:GroupHeaderControl.Resources>
                        <DataTemplate DataType="{x:Type xcdg:Group}">
                           <StackPanel Orientation="Horizontal">
                              <TextBlock Text="{Binding Path=Items[0][FirstName]}" />
                              <TextBlock Text=" " />
                              <TextBlock Text="{Binding Path=Items[0][LastName]}" />
                           </StackPanel>
                        </DataTemplate>
                     </xcdg:GroupHeaderControl.Resources>
                  </xcdg:GroupHeaderControl>
               </DataTemplate>
            </xcdg:GroupHeaderFooterItemTemplate>
         </xcdg:GroupConfiguration.Headers>
      </xcdg:GroupConfiguration>
    </xcdg:Column.GroupConfiguration>


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
  •  05-14-2008, 10:59 AM Post no. 12259 in reply to 12257

    Re: Custom Group Header

    Works Perfectly!!!!!!  Go Xceed Team!!!!

     

    Thanks! 

View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.