Add Hyperlink to Gantt Column

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

    Posted 07 Dec 2012 Link to this post

    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
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 11 Dec 2012 Link to this post

    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.

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

    Posted 11 Dec 2012 Link to this post

    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  
  5. Answer
    Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 12 Dec 2012 Link to this post

    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.

Back to Top