I'm trying to add a tooltip for my custom column of the fileexplorer - here is the code:
void Grid_ItemDataBound(object sender, GridItemEventArgs e)
{
foreach (GridColumn column in RadFileExplorer1.Grid.MasterTableView.RenderColumns)
{
if ((column is GridTemplateColumn) && (column.HeaderText.Equals("Document Title")))
{
if (e.Item is GridDataItem)
{
GridDataItem gridItem = e.Item as GridDataItem;
string text = gridItem[column.UniqueName].Text;
//this line will show a tooltip
gridItem[column.UniqueName].ToolTip = text;
}
}
}
}
I'm unable to get the value of the cell - can you please help?
5 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 02 Aug 2013, 03:42 AM
Hi Neepa,
I guess you want to show tooltip for a GridTemplateColumn.Please try the below sample code snippet.In the code snippet I have shown how to access a bound column,as well as a template column,and set the tooltip accordingly. In order to set the tool tip for a column for its datakey value,you can use
gridItem[column.UniqueName].ToolTip = "Column Name:" + gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["UniqueName"].ToString();
ASPX:
C#:
Hope this helps,
Let me know if any concern.
Thanks,
Princy
I guess you want to show tooltip for a GridTemplateColumn.Please try the below sample code snippet.In the code snippet I have shown how to access a bound column,as well as a template column,and set the tooltip accordingly. In order to set the tool tip for a column for its datakey value,you can use
gridItem[column.UniqueName].ToolTip = "Column Name:" + gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["UniqueName"].ToString();
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
onitemdatabound
=
"RadGrid1_ItemDataBound"
>
<
MasterTableView
DataKeyNames
=
"OrderID"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"OrderID"
DataField
=
"OrderID"
HeaderText
=
"OrderID"
/>
<
telerik:GridTemplateColumn
HeaderText
=
"TemplateColumn"
UniqueName
=
"TemplateColumn"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text=' <%# Eval("ShipCity") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
foreach
(GridColumn column
in
RadGrid1.MasterTableView.RenderColumns)
{
if
(column
is
GridTemplateColumn)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem gridItem = e.Item
as
GridDataItem;
string
itemValue = gridItem[
"OrderID"
].Text;
//Access boundcolumn value
Label labeltext = (Label)gridItem.FindControl(
"Label1"
);
//Access template label value
string
text = labeltext.Text;
gridItem[column.UniqueName].ToolTip =
"OrderID: "
+itemValue
//Gives the tool tip value of bound column
// gridItem[column.UniqueName].ToolTip = "ShipCity: " +text;//Give the tooltip value of the template column
}
}
}
}
Hope this helps,
Let me know if any concern.
Thanks,
Princy
0
Neepa
Top achievements
Rank 1
answered on 02 Aug 2013, 12:14 PM
Princy,
It is actually the tooltip for my file explorer's custom column. I'm able to get the tooltip to work but the value it is grabbing is not correct - I want to grab the value that is in the cell.
It is actually the tooltip for my file explorer's custom column. I'm able to get the tooltip to work but the value it is grabbing is not correct - I want to grab the value that is in the cell.
0
Princy
Top achievements
Rank 2
answered on 05 Aug 2013, 04:53 AM
Hi Neepa,
To get the value of the cell for a template column,please try the following code snippet.If this doesn't help,can you please provide your full code.
ASPX:
C#:
Thanks,
Princy
To get the value of the cell for a template column,please try the following code snippet.If this doesn't help,can you please provide your full code.
ASPX:
<
telerik:GridTemplateColumn
HeaderText
=
"TemplateColumn"
UniqueName
=
"TemplateColumn"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text=' <%# Eval("ShipCity") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
foreach
(GridColumn column
in
RadGrid1.MasterTableView.RenderColumns)
{
if
((column
is
GridTemplateColumn) && (column.HeaderText ==
"TemplateColumn"
))
{
if
(e.Item
is
GridDataItem)
{
GridDataItem gridItem = e.Item
as
GridDataItem;
Label labeltext = (Label)gridItem.FindControl(
"Label1"
);
//Access template value
string
text = labeltext.Text;
gridItem[column.UniqueName].ToolTip =
"ShipCity: "
+text;
}
}
}
}
Thanks,
Princy
0
Neepa
Top achievements
Rank 1
answered on 05 Aug 2013, 11:58 AM
Hi Princy,
Here is my full code:
ASPX:
Here is my full code:
ASPX:
<telerik:RadFileExplorer runat="server" ID="RadFileExplorer1"
OnExplorerPopulated="RadFileExplorer1_ExplorerPopulated" OnClientFileOpen="FileExplorer_ClientFileOpen"
EnableOpenFile="true" EnableCopy="false" EnableCreateNewFolder="true" OnItemCommand="RadFileExplorer1_ItemCommand"
ExplorerMode="Default" Width="800px" Height="400px">
</telerik:RadFileExplorer>
C#:protected void Page_Load(object sender, EventArgs e)
{
RadFileExplorer1.Grid.ItemDataBound += new GridItemEventHandler(Grid_ItemDataBound);
}
void Grid_ItemDataBound(object sender, GridItemEventArgs e)
{
foreach (GridColumn column in RadFileExplorer1.Grid.MasterTableView.RenderColumns)
{
if ((column is GridTemplateColumn) && (column.HeaderText.Equals("Document Title")))
{
if (e.Item is GridDataItem)
{
GridDataItem gridItem = e.Item as GridDataItem;
string text = gridItem[column.UniqueName].Text;
//this line will show a tooltip
gridItem[column.UniqueName].ToolTip = text;
}
}
}
}
0
Hello Neepa,
Please refer to the answer to your previous thread for the same question.
We kindly ask you to restrain from opening multiple threads on the same subject so that we could concentrate on your case and better track the issue.
Thank you for the understanding.Regards,
Konstantin Dikov
Telerik
Please refer to the answer to your previous thread for the same question.
We kindly ask you to restrain from opening multiple threads on the same subject so that we could concentrate on your case and better track the issue.
Thank you for the understanding.Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.