Hello Telerik,
I need to change column type of cell from GridViewDynamicHyperlinkColumn to GridViewDataColumn from code behind or data trigger which depend on DataMemberBinding="{Binding status}" that return "Yes" or "No"
eg.
GridView1.ItemSource
fileName = "xxx" , status = "Yes"
fileName = "aaa" , status = "No"
expected result
Column 0 Column 1
Row 0 : xxx : Yes
Row 1 : aaa : No
[row0,col1 (Yes)] should be DynamicHyperlinkColumn to open a file like XAML below
[row1,col1 (No)] should be DataColumn
XAML
Please give me some advice.
Regards,
SweNz
I need to change column type of cell from GridViewDynamicHyperlinkColumn to GridViewDataColumn from code behind or data trigger which depend on DataMemberBinding="{Binding status}" that return "Yes" or "No"
eg.
GridView1.ItemSource
fileName = "xxx" , status = "Yes"
fileName = "aaa" , status = "No"
expected result
Column 0 Column 1
Row 0 : xxx : Yes
Row 1 : aaa : No
[row0,col1 (Yes)] should be DynamicHyperlinkColumn to open a file like XAML below
[row1,col1 (No)] should be DataColumn
XAML
<telerik:RadGridView x:Name="GridView1" AutoGenerateColumns="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding fileName}" Header="Filename" /> <telerik:GridViewDynamicHyperlinkColumn DataMemberBinding="{Binding status}" Header="Upload Status" NavigateUrlMemberPaths="status" NavigateUrlFormatString="{} file:///C:/{0}.xls" TargetName="_blank" /> </telerik:RadGridView.Columns></telerik:RadGridView>Please give me some advice.
Regards,
SweNz
6 Answers, 1 is accepted
0
Accepted
Hi SweNz,
You should use a CellTemplateSelector in this case. Please check the help topic here.
You will have two templates - the first will contain a hyperlink button, the second will have only a textblock.
Depending on the value of the business object the SelectTemplate method will return either the first or the second template.
Hope this helps.
Greetings,
Veselin Vasilev
the Telerik team
You should use a CellTemplateSelector in this case. Please check the help topic here.
You will have two templates - the first will contain a hyperlink button, the second will have only a textblock.
Depending on the value of the business object the SelectTemplate method will return either the first or the second template.
Hope this helps.
Greetings,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
SweNz
Top achievements
Rank 1
answered on 12 Jan 2011, 10:10 AM
Hi Veselin,
Thank for your fastest response. Now I got my expect result GridView but I can't open my Excel file or any webpage when i click Fail hyperlink.
XAML
RESOURCES
C#
give me some more advice please
Regards,
SweNz
Thank for your fastest response. Now I got my expect result GridView but I can't open my Excel file or any webpage when i click Fail hyperlink.
XAML
<telerik:RadGridView x:Name="GridView1" AutoGenerateColumns="False"> <telerik:RadGridView.Columns> <telerik:GridViewDataColumn DataMemberBinding="{Binding fileName}" Header="Filename" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding status}" Header="Upload Status" CellTemplateSelector="{StaticResource myCellTemplateSelector} /> </telerik:RadGridView.Columns></telerik:RadGridView>RESOURCES
<UserControl.Resources> <my:MyCellTemplateSelector x:Key="myCellTemplateSelector"> <my:MyCellTemplateSelector.failStatus> <DataTemplate> <TextBlock Foreground="Red"> <Hyperlink NavigateUri="http://www.google.co.th"> Fail <!--file:///C:/Fail.xls --> </Hyperlink> </TextBlock> </DataTemplate> </my:MyCellTemplateSelector.failStatus> <my:MyCellTemplateSelector.otherStatus> <DataTemplate> <TextBlock Text="{Binding status}"/> </DataTemplate> </my:MyCellTemplateSelector.otherStatus> </my:MyCellTemplateSelector> </UserControl.Resources>C#
public class MyCellTemplateSelector : DataTemplateSelector{ public override System.Windows.DataTemplate SelectTemplate(object item, System.Windows.DependencyObject container) { if (item is ImpObj) { ImpObj obj = item as ImpObj; if (obj.status == "Fail") { return failStatus; } else { return otherStatus; } } return null; } public DataTemplate failStatus { get; set; } public DataTemplate otherStatus { get; set; } }give me some more advice please
Regards,
SweNz
0
Accepted
Hello SweNz,
Actually, in WPF you need to do some additional coding to make the hyperlink open a browser window (you can test with a hyperlink outside RadGridView and it will behaves the same).
Please check this post on how to do it.
Greetings,
Veselin Vasilev
the Telerik team
Actually, in WPF you need to do some additional coding to make the hyperlink open a browser window (you can test with a hyperlink outside RadGridView and it will behaves the same).
Please check this post on how to do it.
Greetings,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
SweNz
Top achievements
Rank 1
answered on 12 Jan 2011, 10:38 AM
Hi Veselin,
Thank you for your help. I appreciate.
Cheers,
SweNz
Thank you for your help. I appreciate.
Cheers,
SweNz
0
Silvan
Top achievements
Rank 1
answered on 15 May 2013, 03:41 PM
Hi
I want declare a DataTemplate with a HyperlinkButton, it shows me the message that the HyperlinkButton is not public:
What i did wrong?
Regards,
Marcel
I want declare a DataTemplate with a HyperlinkButton, it shows me the message that the HyperlinkButton is not public:
<loclink:CellLinkSelector.linkYes> <DataTemplate> <telerik:HyperlinkButton /> </DataTemplate></loclink:CellLinkSelector.linkYes>What i did wrong?
Regards,
Marcel
0
Hello Marcel,
Didie
the Telerik team
Actually RadControls for WPF does not offer such a control.
Regards,Didie
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.