This project has moved and is read-only. For the latest updates, please go here.

simple questions

Oct 14, 2014 at 9:58 AM
Hi,
  • how can i change the rowheight of the datagrid
  • how to hide the group bar on the top
  • how to hide the left row idicator
thanks and good day
Oct 14, 2014 at 2:01 PM
Hi,

1) RowHeight of DataGrid :
Depending on which type of View you are using on the DataGridControl, there are two ways of doing what you wish.

For the TableView, simply set the Style of the DataRow elements to have the Height you need.
<Style TargetType="{x:Type xcdg:DataRow}">
      <Setter Property="Height" Value="40" />
</Style>
For the TableflowView, set its ContainerHeight value to the desired height.
 <xcdg:DataGridControl.View>
      <xcdg:TableflowView ContainerHeight="40" />
 </xcdg:DataGridControl.View>
2) Hide GroupByControl
By default, the view in the grid has a FixedHeader containing a groupByControl and a ColumnManagerRow. To remove the GroupByControl, you need to disable the default FixedHeader and create your own :
 <xcdg:DataGridControl.View>
            <xcdg:TableflowView UseDefaultHeadersFooters="False">
               <xcdg:TableflowView.FixedHeaders>
                  <DataTemplate>
                     <xcdg:ColumnManagerRow />
                  </DataTemplate>
               </xcdg:TableflowView.FixedHeaders>
            </xcdg:TableflowView>
</xcdg:DataGridControl.View>
3) Hide RowSelectorPane
You can use the property ShowRowSelectorPane from the View :
<xcdg:DataGridControl.View>
            <xcdg:TableflowView  ShowRowSelectorPane="False">
</xcdg:TableflowView>
Oct 14, 2014 at 5:50 PM
Edited Oct 14, 2014 at 6:09 PM
worked like a charm !

another questions :):
1) in the standard datagrid i can add a DataGridTemplateColumn and add whatever i want : several bounded fields, action controls ... etc .
how to do the same thing in the toolkit DG please ?

2) i want to style the datarow to add a rounded border container, something like this
Image
i have tried this :
   <Style x:Key="DataRowStyle2" TargetType="{x:Type xcdg:DataRow}">

            <Setter Property="Height" Value="80" />
            <Setter Property="MinHeight" Value="80" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type xcdg:DataRow}">
                        <Border Background="Green">
                            <ContentPresenter HorizontalAlignment="Center"
                                          VerticalAlignment="Center"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
i got the green border but without the content XD
Oct 14, 2014 at 7:48 PM
Hi,

1) DataGridTemplateColumn on Xceed DataGrid :
You can set the property you want on the Column individually :
<xcdg:DataGridControl x:Name="_datagrid" >
         <xcdg:DataGridControl.Resources>
            <DataTemplate x:Key="FirstNameCellContentTemplate">
               <StackPanel Width="20"
                                    Height="30">
                  <Border Background="LightBlue"
                          BorderBrush="Black"
                          BorderThickness="1">
                     <TextBlock Text="{Binding}"
                                FontSize="8"
                                HorizontalAlignment="Center" />
                  </Border>
               </StackPanel>
            </DataTemplate>
            <DataTemplate x:Key="FirstNameCellEditorTemplate">
                 <TextBox Text="{xcdg:CellEditorBinding}"
                          Background="Green" />
            </DataTemplate>
         </xcdg:DataGridControl.Resources>        
         
         <xcdg:DataGridControl.Columns>
            <xcdg:Column FieldName="FirstName"
                                    CellContentTemplate="{StaticResource FirstNameCellContentTemplate}">
               <xcdg:Column.CellEditor>
                  <xcdg:CellEditor EditTemplate="{StaticResource FirstNameCellEditorTemplate}" />
               </xcdg:Column.CellEditor>
            </xcdg:Column>
         </xcdg:DataGridControl.Columns>
</xcdg:DataGridControl>
2) Have DataRows with Green Background and rounded borders :
Re-template the DataRow (xcdg:FixedCellPanel based on default DataRow Template):
<Style TargetType="{x:Type xcdg:DataRow}">
               <Setter Property="Template">
                  <Setter.Value>
                     <ControlTemplate TargetType="{x:Type xcdg:DataRow}">
                        <Border Background="Green"
                                CornerRadius="10">
                           <!-- The PART_CellsHost part designates the Panel to which this Row's Cells should be added.-->
                           <xcdg:FixedCellPanel x:Name="PART_CellsHost"
                                                ColumnStretchMinWidth="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).ColumnStretchMinWidth}"
                                                ColumnStretchMode="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).ColumnStretchMode}"
                                                FixedCellCount="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).FixedColumnCount, Mode=TwoWay}"
                                                FixedColumnDropMarkPen="{Binding RelativeSource={RelativeSource Self}, Path=(xcdg:DataGridControl.DataGridContext).FixedColumnDropMarkPen}"
                                                Margin="{TemplateBinding BorderThickness}" />
                        </Border>
                     </ControlTemplate>
                  </Setter.Value>
               </Setter>
</Style>
Complete doc for Xceed DataGrid can be found here : http://doc.xceedsoft.com/products/XceedWpfDataGrid/
Oct 14, 2014 at 8:32 PM
Edited Oct 14, 2014 at 8:42 PM
duplicated , please delete
Oct 14, 2014 at 8:41 PM
1)Perfect:
now suppose that the datagrid control is bound to and Orders List .
i may add a Customer column field wich is a navigation property of the order object to add customer personal info: name, phone ... etc .
it would work with code above .
but the problem is Sorting
how can i tell to the datagrid to sort the orders by CUSTOMER.FirstName when i click the CUSTOMER column, because it cannot sort by the navigation property object itself .


2) again it worked ,
just need to adapt this to use the itemscontainer template, a little sleepy right now :)


anyway thanks for your assistance ... really appreciate !
Oct 15, 2014 at 2:13 PM
Hi,

1) Sorting Customer.FirstName.
Sorting is done on the FieldName of the Column. If the fieldName is "Customer", you can use a CellContentTemplate to display Customer.FirstName or Customer.LastName, but sorting will be done on Customer (DataGrid won't know how to sort). You could use DataGridItemProperties and add a SortComparer like examples here : http://doc.xceedsoft.com/products/XceedWpfDataGrid/#Sorting_Data.html.

But in the end, it is now the best option. Its is better to use 1 column per property : Column1.FieldName = Customer.FirstName, Column2.FieldName = Customer.LastName...This way, sorting will work and all DataGrid options willl work (inserting Customer.FirstName instead of Customer, filtering by Customer.FirstName instead of by Customer, editing Customer.FirstName instead of Customer...). You will not by pass the DataGrid's provided technology.