What is the simplest way to call a javascript funcrtion from a GridViewHyperlinkColumn or a GridViewDynamicHyperlinkColumn (directly or with code behind?
For now, I've created a custom column with an HyperlinkButton, but the UI rendering is not the same as the 2 out of the box columns. What I would like to see is a Command implementation with parameters, similar to the GridViewDynamicHyperlinkColumn's NavigateUrlFormatString and NavigateUrlMemberPaths property.
public
class
GridViewItemLinkColumn : GridViewDynamicHyperlinkColumn
{
public
override
FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell,
object
dataItem)
{
this
.BindingTarget = HyperlinkButton.ContentProperty;
HyperlinkButton btn =
new
HyperlinkButton();
btn.Click +=
new
RoutedEventHandler(btn_Click);
btn.SetBinding(
this
.BindingTarget,
this
.CreateValueBinding());
return
btn;
}
void
btn_Click(
object
sender, RoutedEventArgs e)
{
string
str =
this
.DataControl.Items.IndexOf(((HyperlinkButton)sender).DataContext).ToString();
}
private
Binding CreateValueBinding()
{
Binding valueBinding =
new
Binding();
valueBinding.Mode = BindingMode.TwoWay;
valueBinding.NotifyOnValidationError =
true
;
valueBinding.ValidatesOnExceptions =
true
;
valueBinding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
valueBinding.Path =
new
PropertyPath(
this
.DataMemberBinding.Path.Path);
return
valueBinding;
}
}