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

RadGridView Banded Column Header

1 Answer 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Berkay
Top achievements
Rank 1
Berkay asked on 08 Feb 2012, 03:07 PM
Hi,

We are using DevExpress wpf datagrid in our projects but we came into conflict on a very critical issue. We are creating our columns dynamically in a way compliant to MVVM pattern in our project. The column headers of columns created dynamically contains date information(year and week of year) as it can be seen in unbanded.png attached. but we want the column headers to be banded according to year month week  hierarchy as it is explained in banded.png attached. I have also attached the sample code that creates the columns.

This is a very critical issue for us because most of our project's  functionality comes from Grid. If Telerik grid can give us this flexibility we will be giving back our license to DevExpress and buy Telerik licenses for developers. We are on a very critical time schedule any solid proof (based on sample) that this can be done by telerik component will lead us to change our component source. Urgent response will be appreciated.

Thanks

XAML

<Window x:Class="DynamicColumnSample.MainWindow"
        xmlns:local="clr-namespace:DynamicColumnSample"
        xmlns:my="clr-namespace:DynamicColumnSample.Objects"
        xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" Title="MainWindow"
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" xmlns:DynamicColumnSanple="clr-namespace:DynamicColumnSample"
        Width="525"
        Height="364">
    <Window.DataContext>
        <local:ViewModel />
    </Window.DataContext>
    <Window.Resources>
        <my:ColumnTemplateSelector x:Key="ColumnTemplateSelector" />
        <DataTemplate x:Key="DefaultColumnTemplate">
            <ContentControl>
                <dxg:GridColumn AllowEditing="False"
                                    my:ColumnBindingHelper.BindingPath="{Binding FieldName}"
                                    Header="{Binding Header}" />
            </ContentControl>
        </DataTemplate>
        <DataTemplate x:Key="TextColumnTemplate">
            <ContentControl>
                <dxg:GridColumn AllowEditing="True"
                                    my:ColumnBindingHelper.BindingPath="{Binding FieldName}"
                                Header="{Binding Header}"
                                   >
                  
                    <dxg:GridColumn.EditSettings>
                        <dxe:TextEditSettings Tag="{Binding Path=Tag}" ToolTip="{Binding Path=ToolTip}" />
                    </dxg:GridColumn.EditSettings>
                </dxg:GridColumn>
            </ContentControl>
        </DataTemplate>
 
    </Window.Resources>
    <Grid>
        <dx:PopupBase Name="hitInfoPopup" Placement="Mouse" PlacementTarget="{Binding ElementName=treeListStoreUnitSchedule}" Opened="hitInfoPopup_Opened">
            <Grid Width="250" Height="250" Background="Beige">
                <Border Padding="12,8,24,10">
                    <ItemsControl Name="hitIfoItemsControl">
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <StackPanel Orientation="Horizontal" >
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                    <TextBlock Text="{Binding Text}"></TextBlock>
                                </StackPanel>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                </Border>
            </Grid>
        </dx:PopupBase>
        <dxg:GridControl x:Name="treeListStoreUnitSchedule"
                             
                             Grid.Row="1"
                             ColumnGeneratorTemplateSelector="{StaticResource ColumnTemplateSelector}"
                             ColumnsSource="{Binding GridColumns}"
                             ItemsSource="{Binding RegionObjects}">
            <dxg:GridControl.Resources>
                <my:CustomChildrenSelector x:Key="childrenSelector" />
            </dxg:GridControl.Resources>
            <dxg:GridControl.View>
 
                <dxg:TreeListView x:Name="view"
                                  ChildNodesSelector="{StaticResource childrenSelector}"
                                  TreeDerivationMode="ChildNodesSelector"
                                  local:TreeListExpandedNodesHelper.SynchIsExpanded="True"
                                  >
                    
                    <dxg:TreeListView.RowCellMenuCustomizations>
                        <dxb:BarCheckItem Name="checkItem1" Content="Checked" IsChecked="True" dxb:BarItemLinkActionBase.ItemLinkIndex="0" />
                        <dxb:BarItemLinkSeparator dxb:BarItemLinkActionBase.ItemLinkIndex="1" />
                    </dxg:TreeListView.RowCellMenuCustomizations>
 
                    <dxg:TreeListView.CellTemplate>
                        <DataTemplate>
                            <Border
BorderBrush="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dxg:GridCellContentPresenter}}, Path=BorderBrush}"
BorderThickness="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dxg:GridCellContentPresenter}}, Path=BorderThickness}">
                                <dxe:TextEdit x:Name="PART_Editor"/>
                            </Border>
                        </DataTemplate>
                    </dxg:TreeListView.CellTemplate>
 
                </dxg:TreeListView>
            </dxg:GridControl.View>
        </dxg:GridControl>
        <Button  Command="{Binding Path=AddCommand}" Content="Button" Height="23" HorizontalAlignment="Left" Margin="321,0,0,0" Name="button1" VerticalAlignment="Top" Width="75" />
    </Grid>
</Window>


ViewModel

private void PopulateMonthList() {
           try {
               ObservableCollection<MonthInfo> tmpMonthInfo = new ObservableCollection<MonthInfo>(){
                                                           new MonthInfo(){MonthName="2011-01", MonthNumber=201101},
                                                           new MonthInfo(){MonthName="2011-02", MonthNumber=201102},
                                                           new MonthInfo(){MonthName="2011-03", MonthNumber=201103},
                                                           new MonthInfo(){MonthName="2011-04", MonthNumber=201104},
                                                           new MonthInfo(){MonthName="2011-05", MonthNumber=201105},
                                                           new MonthInfo(){MonthName="2011-06", MonthNumber=201106},
                                                           new MonthInfo(){MonthName="2011-07", MonthNumber=201107},
                                                           new MonthInfo(){MonthName="2011-08", MonthNumber=201108},
                                                           new MonthInfo(){MonthName="2011-09", MonthNumber=201109},
                                                           new MonthInfo(){MonthName="2011-10", MonthNumber=201110},
                                                           new MonthInfo(){MonthName="2011-11", MonthNumber=201111},
                                                           new MonthInfo(){MonthName="2011-12", MonthNumber=201112},
                                                           new MonthInfo(){MonthName="2012-01", MonthNumber=201201},
                                                           };
               TextColumn txtColumn = null;
 
               for (int i = 0; i < 13; i++) {
 
                   txtColumn = new TextColumn();
                   txtColumn.FieldName = "SalesInfoObject[" + i.ToString() + "].Quantity";
                   txtColumn.Header = tmpMonthInfo[i].MonthName.ToString();
                   txtColumn.Setting = SettingsType.Text;
                   txtColumn.Tag = "SalesInfoObject[" + i.ToString() + "]";
                   txtColumn.ToolTip = "SalesInfoObject[" + i.ToString() + "]" + "].Brand";
                   _gridColumns.Add(txtColumn);
               }
 
               _gridColumns.Insert(0, new GridColumn() { Header = "Store Region", FieldName = "Name", Setting = SettingsType.Default });
               _gridColumns.Insert(1, new GridColumn() { Header = "Store Quantity", FieldName = "Count", Setting = SettingsType.Default });
               OnPropertyChanged("GridColumns");
 
           } catch (Exception ex) {
 
               throw ex;
           }


1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Feb 2012, 03:10 PM
Hi,

 Please check this demo for more info. The example is for Silverlight however you will find exactly the same in your local copy our of WPF demos. 

Kind regards,
Vlad
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
GridView
Asked by
Berkay
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or