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

[Solved] Sorting of tasks in the GanttView's Grid

6 Answers 215 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Prolay
Top achievements
Rank 1
Prolay asked on 21 Nov 2012, 02:03 PM
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

6 Answers, 1 is accepted

Sort by
0
Accepted
Miroslav Nedyalkov
Telerik team
answered on 21 Nov 2012, 04:18 PM
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.

0
Prolay
Top achievements
Rank 1
answered on 22 Nov 2012, 08:11 AM

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

 

 

 

 

0
Accepted
Ventzi
Telerik team
answered on 27 Nov 2012, 08:26 AM
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.

0
Jaron
Top achievements
Rank 1
answered on 01 Mar 2013, 11:39 PM
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. 
0
Miroslav Nedyalkov
Telerik team
answered on 04 Mar 2013, 03:51 PM
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.

0
Jaron
Top achievements
Rank 1
answered on 04 Mar 2013, 04:43 PM
Miroslav,
 I am new to the Telerik toolset and am very impressed with the product. Additionally many thanks for the immediate support!
Regards
Jaron
Tags
GanttView
Asked by
Prolay
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Prolay
Top achievements
Rank 1
Ventzi
Telerik team
Jaron
Top achievements
Rank 1
Share this question
or