or
We have a text element on the left hand side, and a button on the right hand side of the treeview row. We want to use a context menu which only gets activated when the blue image button is clicked. What actually happens is the context menu is activated when we click anywhere on the treeview row (see picture attached).
We are using this nodetemplate in the RadTreeView with a context menu.
<
NodeTemplate
>
<
div
style
=
"width:100%;height:22px;"
>
<
span
style
=
"float:left;font-family:Arial;font-weight:bold;font-size:13px;"
>
<%# DataBinder.Eval(Container, "Text") %>
</
span
>
<
img
class
=
"treeGear"
src
=
"../img/gearsbluebtn.png"
alt
=
"Options"
width
=
"38px"
height
=
"22px"
/>
</
div
>
</
NodeTemplate
>
How can we limit the context menu to only activate when the blue button is clicked?
<
telerik:RadComboBox
ID
=
"rdcmb"
CheckBoxes
=
"true"
runat
=
"server"
EmptyMessage
=
"Status"
DropDownWidth
=
"200px"
MaxHeight
=
"140px"
Width
=
"200px"
>
</
telerik:RadComboBox
>
if (rdcmb.CheckedItems != null)
{
status = string.Empty;
var sb = new StringBuilder();
var collection = rdcmb.CheckedItems;
foreach (var item in collection)
sb.Append(item.Value + ",");
String ApplicationVariable= sb.ToString();
}
<%@ Import Namespace="Data" %>
<%@ Import Namespace="Photo" %>
Imports System
Imports System.Collections.Generic
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Linq
Imports System.Web
Imports System.Drawing
Namespace Data
Public NotInheritable Class DataProvider
Private Sub New()
End Sub
<
ThreadStatic
()> _
Private Shared _photos As List(Of Photo)
Public Shared Function GetData() As IList(Of Photo)
If _photos IsNot Nothing Then
Return _photos
End If
_photos = New List(Of Photo)()
For Each files As String In Directory.GetFiles(HttpContext.Current.Server.MapPath("~/Images"))
Dim photo = New Photo() With { _
.Name = Path.GetFileName(files) _
}
Dim image__1 As Image = Image.FromFile(files)
Using memoryStream = New MemoryStream()
image__1.Save(memoryStream, ImageFormat.Png)
photo.Data = memoryStream.ToArray()
End Using
_photos.Add(photo)
Next
Return _photos
End Function
Public Shared Sub Update(ByVal photoId As Integer, ByVal name As String)
Dim first As Photo = _photos.FirstOrDefault(Function(p) p.Id = photoId)
If first IsNot Nothing Then
first.Name = name
End If
End Sub
End Class
End Namespace
Public Class Photo
Private Shared ReadOnly _key As New Object()
Private Shared _counter As Integer
Public Sub New()
Id = GetId()
End Sub
Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal value As String)
m_Name = Value
End Set
End Property
Private m_Name As String
Public Property Data() As Byte()
Get
Return m_Data
End Get
Set(ByVal value As Byte())
m_Data = Value
End Set
End Property
Private m_Data As Byte()
Public Property Id() As Integer
Get
Return m_Id
End Get
Private Set(ByVal value As Integer)
m_Id = Value
End Set
End Property
Private m_Id As Integer
Protected Shared Function GetId() As Integer
SyncLock _key
_counter += 1
End SyncLock
Return _counter
End Function
End Class
<
ItemTemplate
>
<
fieldset
style="float: left; margin: 5px 5px 5px 5px; padding: 2px 2px 2px 2px;
background: #eeeeee"
class
=
"myClass"
onmouseover
=
"containerMouseover(this)"
onmouseout
=
"containerMouseout(this)"
>
<
telerik:RadBinaryImage
Style
=
"cursor: pointer;"
runat
=
"server"
ID
=
"RadBinaryImage1"
DataValue='<%#Eval("Data") %>' Height='<%#ImageHeight %>' Width="<%#ImageWidth %>"
ResizeMode="Fit" onclick="<%#CreateWindowScript(DirectCast(Container.DataItem, Photo)) %>"
AlternateText="Click to view larger image" ToolTip="Click to view larger image" />
<
br
/>
<
div
style="margin-top: -30px; position: fixed; display: none; width: <%#ImageHeight.Value/1.5 %>px;">
<
asp:TextBox
runat
=
"server"
ID
=
"TextBox1"
Text='<%#Bind("Name") %>' CssClass="txt"
OnTextChanged="TextBox1_TextChanged" AutoPostBack="true" ToolTip="Edit image name" />
</
div
>
</
fieldset
>
</
ItemTemplate
>
<telerik:RadPanelBar ID="RadPanelBar1" runat="server" Skin="Outlook" BorderWidth="0px"> |
<Items> |
<telerik:RadPanelItem Text="Locations" Expanded="true" BorderWidth="0px"> |
<ItemTemplate><p>Hello Telerik</p></ItemTemplate> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelBar> |