I am using a radgrid in my application as given below.
<telerik:RadGrid ID="RadGridMeasuresList" runat="server" AllowPaging="True" AutoGenerateColumns="False" Width="700px" ShowFooter="false" Skin="WebBlue" BorderColor="White" BackColor="White" ItemStyle-BorderColor="Black" Height="300px" HeaderStyle-ForeColor="Black" onitemdatabound="RadGridMeasuresList_ItemDataBound" onitemcreated="RadGridMeasuresList_ItemCreated">
<ItemStyle BorderColor="Black" />
<MasterTableView>
<Columns>
<telerik:GridBoundColumn HeaderText="Measure" DataField="MeasureName" HeaderStyle-Wrap="false" ItemStyle-Wrap="true" HeaderStyle-Width="250px" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText = "Total Opportunities" DataField="Opportunities" HeaderStyle-Wrap="false" UniqueName="Opportunities" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">
<ItemStyle Wrap="True"/>
</telerik:GridBoundColumn >
<telerik:GridHyperLinkColumn HeaderText = "Patients with Clinical Alerts" DataTextField="NonComplianceCount" ItemStyle-HorizontalAlign="Left" UniqueName="NonComplianceCount" HeaderStyle-Font-Bold="false" HeaderStyle-Wrap="false" DataNavigateUrlFields="Condition,Measure" DataNavigateUrlFormatString="IPClinicalAlerts.aspx?Condition={0}&Measure={1}&IsCompliant=False&PatientSearch=0" HeaderStyle-Width="150px">
<ItemStyle Wrap="True" Font-Underline="true"/>
</telerik:GridHyperLinkColumn>
<telerik:GridBoundColumn HeaderText = "Compliance Rate" DataField="Rate" HeaderStyle-Wrap="false" UniqueName="Rate" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">
<ItemStyle Wrap="True" />
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<HeaderStyle BackColor="#E1E1E1" Font-Bold="True"/>
<clientsettings enablerowhoverstyle="True" >
<selecting allowrowselect="True" />
<scrolling AllowScroll="true" usestaticheaders="True" />
</clientsettings>
</telerik:RadGrid>
Here are the 2 problems i am facing
1.When i view this grid in browser i am not getting a Underline for the values in the Hyperlink column even after setting Underline property as true for the Items. Even i tried setting using CssClass but i am not able to acheive it.
2.On mouse over the values in the HyperLink columns i am getting a tooltip displaying the same values. How to hide the tooltip.
Thanks in advance,
Sharath
12 Answers, 1 is accepted
I did not experience this issue on my end, even I tried in IE, firefox and Opeara browsers. Make sure that you have not applied any style which overrides the default properties of HyperLink.
Now for hiding the ToolTip of HyperLinkColumn, access the HyperLink from code behind and set ToolTip as empty like below.
C#:
protected void RadGridMeasuresList_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
GridDataItem item = (GridDataItem)e.Item; |
HyperLink link = (HyperLink)item["NonComplianceCount"].Controls[0]; |
link.ToolTip = ""; |
} |
} |
Thanks,
Princy.
Before it navigates to the given page, I want few values to be stored in a session var.
Which event will be triggered when the user clicks on the hyperlink? can it be modified to trigger the itemcommand event?
1st method:
Try catching the hyperlink using the Item Created and using the onclick event you can attach your javascript.
C#:
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
HyperLink link = (HyperLink)item[
"ColUniqueName"
].Controls[0];
link.Attributes.Add(
"onclick"
,
"Validate(); return false;"
);
}
}
<script type=
"text/javascript"
>
function
Validate()
{
alert(
"Not an authorized user"
);
}
</script>
aspx:
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"btnlnk"
runat
=
"server"
Text='<%# Eval("ColUniqueName") %>' OnClick="btnlnk_Click">
</
asp:LinkButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
protected
void
btnlnk_Click(
object
sender, EventArgs e)
{
LinkButton btnlnk = sender
as
LinkButton;
GridDataItem item = btnlnk.NamingContainer
as
GridDataItem;
//your functionality
}
Thanks,
Princy.
Got it working.
Not sure how but ,Since i already had a gridbuttoncloumn, clicking the hyperlink triggers the item command event as well.
Hence smoothly working.
Is it a risky process??
Explain about radgrid index..bcoz am displaying s.no and somemsg in two coloumns if am chking indexes
it is showing s.no is cells[2] and somemsg is cells[3] and wat abt [0],[1]
The column index starts at index 2 beacuse GridExpandColumn and GridRowindicatorColumn are always in front of data columns.
Because of features such as column reordering and grouping, the index of individual columns can change on the client. This means that using indexes to access individual cells in the Cells collection of a row is not a reliable method of obtaining a cell in a particular column.
You can also access the cell using its Column's UniqueName.
Thanks,
-Shinu.
I have a hyperlink column in my radgrid.How can i get the value of hyperlink column value in item data bound event?
Please try the following code snippet to access the GridHyperlinkColumn in ItemDataBound event.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem ditem = (GridDataItem)e.Item;
HyperLink hyper = (HyperLink)ditem[
"UniqueName"
].Controls[0];
string
value = hyper.Text;
}
}
Thanks,
Princy.
If a have a button in the same row of the chyperlink column.How can i get the hyperlink column value in the button click event.(Not in the onclick event)? like the below function:
protected void btnChange_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridDataItem item = (GridDataItem)btn.NamingContainer;
TableCell cell1 = (TableCell)item["Name"];
string clvalue = cell.Text;
}
Please take a look into the following code snippet.
C#:
protected
void
Button1_Click(
object
sender, EventArgs e)
{
Button btn = (Button)sender;
GridDataItem ditem = (GridDataItem)btn.NamingContainer;
HyperLink hyper = (HyperLink)ditem[
"UniqueName"
].Controls[0];
// access the hyperlink here
}
Thanks,
Princy.