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

[Solved] GroupViewModel does not contain whole object of binding just like SeedItem in Silverlight Grid

1 Answer 242 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.
Dipti
Top achievements
Rank 1
Dipti asked on 29 Jul 2011, 11:46 AM
Hi,

I was used Silverlight DataGrid, when i am converting this datagrid to telerik grid my functionality is breaking.
Below is my code, which binding with property and having two way binding and its working fine in silverlight grid and not in telerik grid.
In Silverlight Grid, there have SeedItem property CollectionViewGroupInternal which contains all whole object of binding. But i am not able to see that whole object in telerik. only i m getting the property which i grouped by.

<data:DataGrid.RowGroupHeaderStyles>
 <Style TargetType="data:DataGridRowGroupHeader">
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate>
      <StackPanel Orientation="Horizontal"  Background="#FF112255"  VerticalAlignment="Center">
       <CheckBox  IsChecked="{Binding Items[0].IsChecked, Mode=TwoWay}"  Margin="5,0,0,0" HorizontalAlignment="Right" ></CheckBox>
       <TextBlock Foreground="#FFEEEEEE" Text="{Binding Path=Items[0].PACK_DESC}" HorizontalAlignment="Left" />
      </StackPanel>
     </ControlTemplate>
    </Setter.Value>
   </Setter>
 </Style>
</data:DataGrid.RowGroupHeaderStyles>

Could u please tell me how to achieve/access whole object in to bind it in GroupHeaderTemplate.



1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 01 Aug 2011, 09:34 AM
Hello Dipti,

 

When you group the data in RadGridView you add a GroupDescriptor to a collection which define the grouping criteria for the RadGridView's data.The Member property defines the property, by which the data will be grouped, and the SortDirection property allows you to define the direction by which the groups will be sorted. The Key property represents the items that are stored in this particular column. The GroupHeaderTemplate represents DataTemplate which is applied to the GridViewGroupRow's header.
You may define it on a RadGridView level and on a GridViewColumn level to define the desired UI when the grid is grouped:


<telerik:RadGridView  x:Name="gridView" AutoGenerateColumns="False" ItemsSource="{Binding Collection}">
  
            <telerik:RadGridView.GroupDescriptors>
  
                <telerik:GroupDescriptor Member="Property2"/>
  
                <telerik:GroupDescriptor Member="Property3"/>
  
                </telerik:RadGridView.GroupDescriptors>
  
            <telerik:RadGridView.Columns>
  
                <telerik:GridViewDataColumn  Header="CompanyName" DataMemberBinding="{Binding Property1}"/>
  
                <telerik:GridViewDataColumn Header="EmployeeName" DataMemberBinding="{Binding Property2}">
  
                    <telerik:GridViewDataColumn.GroupHeaderTemplate>
  
                        <DataTemplate>
  
                            <StackPanel Orientation="Horizontal">
  
                              <CheckBox/>
  
                              <TextBlock Text="{Binding GroupDescriptor.Member}" Margin="5"/>
  
                                   <TextBlock Text="{Binding Group.Key}" Margin="5"/>
  
                            </StackPanel>
  
                            </DataTemplate>
  
                        </telerik:GridViewDataColumn.GroupHeaderTemplate>
  
                    </telerik:GridViewDataColumn>
  
  
                </telerik:RadGridView.Columns>
  
            </telerik:RadGridView>


You may read more about grouping in our online documentation, follow this link. 


Greetings,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
GridView
Asked by
Dipti
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or