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

Sort a Custom Column

1 Answer 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
StevenDale
Top achievements
Rank 2
StevenDale asked on 23 Aug 2010, 04:31 AM
I have a the following column definition:  I want to be able to sort this column on the Sailor.Name property. How do I accomplish this?

Thanks in advance,

<telerik:GridViewColumn Width="*" Header="Sailor" IsSortable="True" >
  <telerik:GridViewColumn.CellTemplate>
    <DataTemplate>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock Text="{Binding Name}" />
        <Image Source="{DynamicResource User_Man_Padlock}" Grid.Column="1" Margin="0,0,10,0" ToolTip="{Binding DetailRequisitionAssignedTo, Converter={StaticResource DetailRequisitionConverter}}" Height="15"  >
          <Image.Visibility>
            <MultiBinding Converter="{StaticResource SailorLockVisibilityConverter}" ConverterParameter="Left">
              <Binding Path="DetailRequisitionAssignedTo" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SailorsOnLeft" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SelectedJobInformation" />
            </MultiBinding>
          </Image.Visibility>
        </Image>
        <Image Source="{DynamicResource Padlock}" Grid.Column="1" Margin="0,0,10,0" ToolTip="{Binding DetailRequisitionAssignedTo, Converter={StaticResource DetailRequisitionConverter}}" Height="15"  >
          <Image.Visibility>
            <MultiBinding Converter="{StaticResource SailorLockVisibilityConverter}" ConverterParameter="Right">
              <Binding Path="DetailRequisitionAssignedTo" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SailorsOnLeft" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SelectedJobInformation" />
            </MultiBinding>
          </Image.Visibility>
        </Image>
        <Image Source="{DynamicResource User_Man_Padlock}" Grid.Column="1" Margin="0,0,10,0" ToolTip="{Binding DetailRequisitionAssignedTo, Converter={StaticResource DetailRequisitionConverter}}" Height="15"  >
          <Image.Visibility>
            <MultiBinding Converter="{StaticResource SailorLockVisibilityConverter}" ConverterParameter="AssignedTo">
              <Binding Path="DetailRequisitionAssignedTo" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SailorsOnLeft" />
              <Binding RelativeSource="{RelativeSource AncestorType={x:Type local:MainWindow}}" Path="DataContext.SelectedJobInformation" />
            </MultiBinding>
          </Image.Visibility>
        </Image>
      </Grid>
    </DataTemplate>
  </telerik:GridViewColumn.CellTemplate>
</telerik:GridViewColumn>

Billy Jacobs

1 Answer, 1 is accepted

Sort by
0
Accepted
Milan
Telerik team
answered on 23 Aug 2010, 07:42 AM
Hi Billy Jacobs,

You just have to use GridViewDataColumn instead of GridViewColumn and set DataMemberBinding on the column ("Sailor.Name").


Sincerely yours,
Milan
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
Tags
GridView
Asked by
StevenDale
Top achievements
Rank 2
Answers by
Milan
Telerik team
Share this question
or