Sorting of tasks in the GanttView's Grid

7 posts, 2 answers
  1. Prolay
    Prolay avatar
    27 posts
    Member since:
    Nov 2012

    Posted 21 Nov 2012 Link to this post

    Hi,

    I need to develop a sorting functionality for a few columns by clicking on the grid header.
    Can anyone suggest me a method to do it.
    I have put a hyperlink button in the ContentTemplate of ColumnHeaderContainer. I am unable to figure out the way to attach a command to the HyperlinkButton.
    If there can be a better approach than this please suggest.

    <Style x:Key="ColumnHeaderContainerStyle" TargetType="gantt:ColumnHeaderContainer">
            <Setter Property="SubitemsPadding" Value="0" />
            <Setter Property="SubitemsGap" Value="0" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="gantt:ColumnHeaderContainer">
                        <Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"
                                BorderThickness="{TemplateBinding BorderThickness}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <ToggleButton IsChecked="{Binding IsExpanded, Mode=TwoWay}" 
                                        Margin="{TemplateBinding Padding}" Style="{StaticResource ExpandToggleButtonStyle}" 
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Foreground="{TemplateBinding Foreground}"
                                        ContentTemplate="{TemplateBinding ContentTemplate}" Content="{Binding SourceItem}" />
                                <!--IsEnabled="{Binding CanExpand}"-->
                            </Grid>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <HyperlinkButton Content="{Binding Header}" />
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
     

    Thanks and Regards
    Prolay
  2. Answer
    Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 21 Nov 2012 Link to this post

    Hi Prolay,

    Please refer to the attached example that demonstrates how to implement sorting like in a normal GridView control with some custom behavior.

    Hope this helps.

    Regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Prolay
    Prolay avatar
    27 posts
    Member since:
    Nov 2012

    Posted 22 Nov 2012 Link to this post

    Hi Miroslav,

    It worked great. I am able to do the sorting in silverlight GanttView.
    However i need to stop the header click on certain columns. Is there a way to do it.


    Regards,

    Prolay

     

     

     

     

  5. Answer
    Ventzi
    Admin
    Ventzi avatar
    114 posts

    Posted 27 Nov 2012 Link to this post

    Hello Prolay,

    The easiest way to prevent a click on particular header is to restrict his value on line 102 in the ColumnHeaderExtensions class like follow:

    if (columnDefinition != null && columnDefinition.Header.ToString() != "Start") {...}

    I hope this helps.

    Greetings,
    Ventzi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Jaron
    Jaron avatar
    2 posts
    Member since:
    Jul 2012

    Posted 01 Mar 2013 Link to this post

    Hi Miroslav,
    I was looking for an example similar to the GanttGridSorting solution you forwarded to Prolay. However I cannot find the Telerik.Windows.Core reference in the WPF Q1 2013 assemblies. I am using VS 2012. Could you refactor the example so that I may examine it. Thanks for your time. 
  7. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 04 Mar 2013 Link to this post

    Hi Jaron,

    The Telerik.Windows.Core.dll is not needed with the latest version of RadControls for Silverlight and WPF, so you can just delete the reference and everything will be fine.

    The most recent version of the example can be found here.

    Kind regards,
    Miroslav Nedyalkov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Jaron
    Jaron avatar
    2 posts
    Member since:
    Jul 2012

    Posted 04 Mar 2013 Link to this post

    Miroslav,
     I am new to the Telerik toolset and am very impressed with the product. Additionally many thanks for the immediate support!
    Regards
    Jaron
Back to Top
DevCraft banner