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

Add Hyperlink to Gantt Column

3 Answers 149 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Prolay
Top achievements
Rank 1
Prolay asked on 07 Dec 2012, 07:28 AM
Hi,

I need to change the column type to hyperlink button so that a method can be called in code behind.

I am trying to do something like this but the data in now shown for the column. However if i remove the CellTemplate data is shown properly.

<telerik:ColumnDefinition MemberBinding="{Binding Project}" Header="Project " ColumnWidth="100">
    <telerik:ColumnDefinition.CellTemplate>
        <DataTemplate>
            <HyperlinkButton x:Name="hbProject" Content="{Binding Owner.Project}" Click="hbProject_Click" />
        </DataTemplate>
    </telerik:ColumnDefinition.CellTemplate>
</telerik:ColumnDefinition>

Please help me on this.


Thanks and Regards
Prolay

3 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 11 Dec 2012, 12:47 PM
Hello Prolay,

When you set a new DataTemplate for the ColumnDefinition.CellTemplate you will need to include all the wanted fields (like the Header). All you need to do is set an appropriate DataTemplate.

The next code snippet shows how to create a custom DataTemplate that only adds a HyperlinkButton to the
existing column:
<telerik:TreeColumnDefinition Header="Title" MemberBinding="{Binding Title}" ColumnWidth="250">
    <telerik:ColumnDefinition.CellTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Title}"/>
                <HyperlinkButton x:Name="hbProject" Content="HyperlinkButton" Margin="10 0 0 0"/>
            </StackPanel>
        </DataTemplate>
    </telerik:ColumnDefinition.CellTemplate>
</telerik:TreeColumnDefinition>

Hope this is helpful.

All the best,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Prolay
Top achievements
Rank 1
answered on 11 Dec 2012, 02:24 PM
Hi Vladi,

I want the text of the column in the hyperlink button so that it becomes clickable. I am unable to achieve this with the code you have given. When i apply a DataTemplate the data itself disappears. I have attached screenshots.


Regards,
Prolay  
0
Accepted
Vladi
Telerik team
answered on 12 Dec 2012, 03:58 PM
Hello Prolay,

Binding the Title, Start and End properties can be done with the approach I described in my previous response. Binding the other properties of the GanttTask or a custom property in the CellTemplate is a bit different and you will need to access it from the OriginalEvent proxy. This is done for optimization purposes.

The next code snippet shows how to bind the Description property of the GanttTask:
<telerik:ColumnDefinition Header="Description" MemberBinding="{Binding OriginalEvent.Description}" ColumnWidth="250">
    <telerik:ColumnDefinition.CellTemplate>
        <DataTemplate>
            <HyperlinkButton x:Name="hbProject" Content="{Binding OriginalEvent.Description}" />
        </DataTemplate>
    </telerik:ColumnDefinition.CellTemplate>
</telerik:ColumnDefinition>

If you have any other questions feel free to write to us again.

Greetings,
Vladi
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GanttView
Asked by
Prolay
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Prolay
Top achievements
Rank 1
Share this question
or