Hi,
is it possible to make a whole row in a grid a hyperlink?
So when the user moves the mouse over thr row, no matter in what field, he can click the whole row and is redirected?
Thanks in advance for your help
Best regards
Thomas
is it possible to make a whole row in a grid a hyperlink?
So when the user moves the mouse over thr row, no matter in what field, he can click the whole row and is redirected?
Thanks in advance for your help
Best regards
Thomas
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 03 Aug 2010, 11:26 AM
Hello Thomas,
Set the ClientSettings -> EnablePostBackOnRowClick property to True in order to fire the ItemCommand on clicking the row. Now in the ItemCommand event, check for the CommandName whether it is "RowClick" and perform the action based on the row clicked,
-Shinu.
Set the ClientSettings -> EnablePostBackOnRowClick property to True in order to fire the ItemCommand on clicking the row. Now in the ItemCommand event, check for the CommandName whether it is "RowClick" and perform the action based on the row clicked,
-Shinu.
0
Thomas
Top achievements
Rank 1
answered on 03 Aug 2010, 06:29 PM
Hello Shinu,
thank you very much for your quick answer.
How can I now achieve to redirect to a page using an URL that is the value of one of the columns in the row?
The column is called "Artikelnummer" and is filled from a database:
Can I set a CommandArgument?
Thanks again for your help
Best regards
Thomas
thank you very much for your quick answer.
How can I now achieve to redirect to a page using an URL that is the value of one of the columns in the row?
The column is called "Artikelnummer" and is filled from a database:
<
telerik:GridHyperLinkColumn
DataTextField
=
"Artikelnummer"
DataNavigateUrlFields
=
"Artikelnummer, Warengruppe"
DataNavigateUrlFormatString
=
"details.aspx?Artikelnummer={0}&Kategorie={1}"
HeaderText
=
"Artikelnummer"
>
<
ItemStyle
Width
=
"110px"
/>
</
telerik:GridHyperLinkColumn
>
Can I set a CommandArgument?
Thanks again for your help
Best regards
Thomas
0
Thomas
Top achievements
Rank 1
answered on 04 Aug 2010, 07:50 AM
I managed to (kind of) sort this:
Protected
Sub
RadGrid_Suchresultate_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
RadGrid_Suchresultate.ItemCommand
If
e.CommandName =
"RowClick"
AndAlso
TypeOf
e.Item
Is
GridDataItem
Then
e.Item.Selected =
True
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
Dim
str_Artikelnummer
As
String
= dataItem(
"Artikelnummer"
).Text
Dim
str_Warengruppe
As
String
= dataItem(
"Warengruppe"
).Text
Response.Redirect(str_Artikelnummer & str_Warengruppe)
End
If
End
Sub
It the Grid Column is a GridHyperlinColumn, I can't access the Text property, also not the assigned NavigateURL, so I have to do it that way. Is there a way to do retrieve the NaviagateURL from a GridHyperlinColumn in the ItemCommand event?
Thanks
Thomas
0
Thomas
Top achievements
Rank 1
answered on 05 Aug 2010, 08:24 AM
Seems like that can't be done.
Thomas
Thomas
0
Hello Thomas,
You can add the navigate URL fields to the DataKeyNames collection of the master table:
Now you can get the data key values for the clicked item in ItemCommand and build the same url you have in your GridHyperlinkColumn:
All the best,
Veli
the Telerik team
You can add the navigate URL fields to the DataKeyNames collection of the master table:
<
telerik:RadGrid
>
<
MasterTableView
DataKeyNames
=
"Artikelnummer, Warengruppe"
>
<
MasterTableView
>
</
telerik:RadGrid
>
Now you can get the data key values for the clicked item in ItemCommand and build the same url you have in your GridHyperlinkColumn:
Protected
Sub
RadGrid_Suchresultate_ItemCommand(
ByVal
source
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
RadGrid_Suchresultate.ItemCommand
If
e.CommandName =
"RowClick"
AndAlso
TypeOf
e.Item
Is
GridDataItem
Then
e.Item.Selected =
True
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
Dim
str_Artikelnummer
As
String
= (string)dataItem.GetDataKeyValue(
"Artikelnummer"
);
Dim
str_Warengruppe
As
String
= string)dataItem.GetDataKeyValue(
"Warengruppe"
);
Response.Redirect(
String
.Format(
"details.aspx?Artikelnummer={0}&Kategorie={1}"
, str_Artikelnummer, str_Warengruppe))
End
If
End
Sub
All the best,
Veli
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items