I'm looking for a way to modify the alt rsp. tooltip text for ExpandCollapseColumn-ExpandImageUrl and ExpandCollapseColumn-CollapseImageUrl. I want to have different text on several pages e.g. in one page simple "collapse", in an other page "more information" and so on.
I did similar with the filter menu in Page_Load
Dim Menu As GridFilterMenu = RadGrid1.FilterMenu
Dim item As RadMenuItem
For Each item In Menu.Items
item.BackColor = Color.LightGreen
'change the text for the StartsWith menu item
If item.Text = "NoFilter" Then
item.Text = "kein Filter"
End If
And so on.
But I didn't find a similar solution for the ExpandImage and CollapseImage in the ExpandColumn.
Any suggestions, ideas?
Thanks
6 Answers, 1 is accepted
Try the following code snippet in PreRender event to set different ToolTip for ExpandCollapse image in grid pages. Please modify the logic based on your requirement.
C#:
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
foreach
(GridDataItem item
in
RadGrid1.MasterTableView.Items)
{
Button expandcollapsebtn = (Button)item[
"ExpandColumn"
].Controls[0];
if
(item.Expanded)
{
if
(RadGrid1.CurrentPageIndex == 0)
expandcollapsebtn.ToolTip =
"Collapse ToolTip"
;
else
expandcollapsebtn.ToolTip =
"Hide More Information"
;
}
else
{
if
(RadGrid1.CurrentPageIndex == 0)
expandcollapsebtn.ToolTip =
"Expand ToolTip"
;
else
expandcollapsebtn.ToolTip =
"More Information"
;
}
}
Thanks,
Princy.
I tested
expandcollapsebtn.visible = false and the ExpandImage disappears. So the logic seems to work, but not with expandcollapsebtn.tooltip or with expandcollapsebtn.AlternateText.
Regards
Heinz
Please try setting the ExpandTooltip and CollapseTooltip properties in order to implement the desired functionality.
I hope this helps.
Best wishes,
Mira
the Telerik team
Regards
Heinz
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
Culture
=
"de-DE"
DataSourceID
=
"SqlDataSourceGrid1"
Skin
=
"Sunset"
GridLines
=
"None"
Width
=
"630px"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
DataKeyNames
=
"TerminID"
ClientDataKeyNames
=
"TerminID"
ShowHeader
=
"false"
AlternatingItemStyle-BackColor
=
"#ffffff"
DataSourceID
=
"SqlDataSourceGrid1"
AllowPaging
=
"True"
PageSize
=
"5"
NoMasterRecordsText
=
"Für diese Auswahl sind leider keine Einträge vorhanden!"
ExpandCollapseColumn-ButtonType
=
"ImageButton"
ExpandCollapseColumn-ExpandImageUrl
=
"Images/info.gif"
ExpandCollapseColumn-CollapseImageUrl
=
"Images/collapse.gif"
HierarchyDefaultExpanded
=
"false"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"TerminID"
DataType
=
"System.Int32"
HeaderText
=
"TerminID"
ReadOnly
=
"True"
SortExpression
=
"TerminID"
UniqueName
=
"TerminID"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
ItemTemplate
>
<
div
style
=
"width:580px;"
>
<
div
style
=
"margin-top:20px;background:#ffffff;"
></
div
>
<
fieldset
style
=
"padding: 10px;"
>
<
div
style
=
"float:left;"
><%# WeekdayName(Weekday(Eval("Datum")))%>, <%# Eval("Datum", "{0:dd.MM.yyyy}")%>, <%# DisplayTime(Eval("Uhrzeit"))%> - <%# Eval("TypName")%></
div
>
<
div
style
=
"float:right;"
><%# Eval("Festival")%></
div
>
<
div
style
=
"clear:both"
><%# Eval("Ortsname")%>, <%# Eval("LocationName")%></
div
>
<
div
style
=
"clear:both"
><%# Eval("Titel")%></
div
>
<
div
style
=
"clear:both"
><%# Eval("Untertitel")%></
div
>
</
fieldset
>
</
div
>
</
ItemTemplate
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"TerminID"
ShowHeader
=
"false"
DataSourceID
=
"SqlDataSource2"
CssClass
=
"Programm"
runat
=
"server"
GridLines
=
"None"
BorderColor
=
"#ffffff"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"TerminID"
MasterKeyField
=
"TerminID"
/>
</
ParentTableRelation
>
<
ItemTemplate
>
<
div
style
=
"width:90%;"
>
<
fieldset
style
=
"margin-left:5px;padding:10px;"
>
<
legend
style
=
"padding: 5px;font-weight:bold;font-size:12px;"
>Programmdetails zu <%# Eval("Titel")%></
legend
>
<
div
><%# Replace(Eval("Programm"), vbCrLf, "<
br
/>")%></
div
>
<
div
style
=
"text-align:right;"
><%# MakeLink(Eval("Web")) %></
div
>
</
fieldset
>
</
div
>
</
ItemTemplate
>
</
telerik:GridTableView
>
</
DetailTables
>
<
PagerStyle
Mode
=
"NextPrev"
Position
=
"TopAndBottom"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
I have followed your scenario and prepared a sample project for you demonstrating how the desired functionality can be implemented. You can find it attached to this message.
I hope it helps.
All the best,
Mira
the Telerik team
As so often - to lines of code decide on happy or unhappy ;-)