Hi
Im hoping you are able to help me, im quite new to telerik components and so far they work like a treat..
But now i ran into an issue, were i want to create a new TreeListColumn - i found an example in silverlight (i think, it mentioned xaml files), i need a quick simple example of how to do this...
I know i can create it is a TreeListTemplateColumn, but as this is going to be used mutiple times, i think it would be better to create a custom column. But what ever i have tried (user control, inherits from Telerik.Web.UI.TreeListEditableColumn amongst other) have failed.
Do you have a smaple floating somewhere? or are you able to quickly markup a simple sample using a textbox or something?
Thanks
/Stig
6 Answers, 1 is accepted
Are you looking for something similar to the approach demonstrated in the following sample for RadGrid?
http://www.telerik.com/forums/filter-a-template-column-with-values-from-multiple-datafields#lhpEuz9KsEWqdUEkRfgvPQ
Please keep in mind that creating custom controls is beyond our support scope even if they inherit directly form Telerik controls. Instead, I suggest that you create your entire RadTreeList in the code-behind during the Page_Init event handler and built a generic generation for programmatic creation of your template columns:
http://docs.telerik.com/devtools/aspnet-ajax/controls/treelist/defining-structure/programmatic-definition#creating-template-columns-dynamically
I hope this will prove helpful.
Regards,
Eyup
Telerik
Hi Eyup
that example is exactly what i need...
ApostropheInsensitiveColumn : GridBoundColumn
but what class do i need to inherit from when we are talking treelist?
And yes, i had a feeling that my question was outside support scope - but i have found other samples you have created so i just hoped that you had something that perhaps was not published yet.
/Stig
I allmost got it to work , and i hope you are able to help even thou this might be out of scope.
With the help of the two links
http://docs.telerik.com/devtools/aspnet-ajax/controls/treelist/defining-structure/programmatic-definition#creating-template-columns-dynamically
and
https://msdn.microsoft.com/en-us/library/aa479316.aspx
but i have a small problem.... the value isnt "saved" - what have i forgotten:
Namespace CustomColumns
Public Class ValueSetColumn
Inherits TreeListTemplateColumn
Private _valueSet As String
Private ListItems As OrderedDictionary
Public Property ValueSet As String
Get
Return _valueSet
End Get
Set(value As String)
Dim strs As String()
_valueSet = value
For Each Str As String In value.Split(",")
strs = Str.Split("=")
ListItems.Add(strs(0), strs(1))
Next
End Set
End Property
Public Sub New()
Me.ListItems = New OrderedDictionary()
Me.ItemTemplate = New ItemValueSetTemplate(Me)
Me.EditItemTemplate = New EditValueSetTemplate(Me)
End Sub
#Region "EditValueSetTemplate"
Private Class EditValueSetTemplate
Implements IBindableTemplate
Private owner As ValueSetColumn = Nothing
Private ddl As RadDropDownList = Nothing
Public Sub New(owner As ValueSetColumn)
Me.owner = owner
End Sub
Public Function ExtractValues(container As Control) As IOrderedDictionary Implements IBindableTemplate.ExtractValues
Dim values As New OrderedDictionary()
values(owner.DataField) = ddl.SelectedItem.Value
Return values
End Function
Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn
ddl = New RadDropDownList()
ddl.Enabled = True
ddl.MergeStyle(owner.ItemStyle)
AddHandler ddl.DataBinding, AddressOf DataBinding
container.Controls.Add(ddl)
End Sub
Private Sub DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Dim item As DropDownListItem
Dim DDL As RadDropDownList = DirectCast(sender, RadDropDownList)
Dim container As TreeListEditableItem = DirectCast(DDL.NamingContainer, TreeListEditableItem)
Dim selectedvalue As String = DirectCast(container.DataItem, DataRowView)(owner.DataField).ToString()
DDL.Items.Clear()
For Each ditem In owner.ListItems
item = New DropDownListItem(ditem.Key, ditem.Value)
item.Selected = (item.Value = selectedvalue)
DDL.Items.Add(item)
Next
End Sub
End Class
#End Region
#Region "ItemValueSetTemplate"
Private Class ItemValueSetTemplate
Implements IBindableTemplate
Private owner As ValueSetColumn = Nothing
Private ddl As RadDropDownList = Nothing
Public Sub New(owner As ValueSetColumn)
Me.owner = owner
End Sub
Public Function ExtractValues(container As Control) As IOrderedDictionary Implements IBindableTemplate.ExtractValues
Dim values As New OrderedDictionary()
values(owner.DataField) = ddl.SelectedItem.Value
Return values
End Function
Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn
ddl = New RadDropDownList()
AddHandler ddl.DataBinding, AddressOf DataBinding
ddl.MergeStyle(owner.ItemStyle)
ddl.Enabled = False
container.Controls.Add(ddl)
End Sub
Private Sub DataBinding(ByVal sender As Object, ByVal e As EventArgs)
Dim item As DropDownListItem
Dim DDL As RadDropDownList = DirectCast(sender, RadDropDownList)
Dim container As TreeListEditableItem = DirectCast(DDL.NamingContainer, TreeListEditableItem)
Dim selectedvalue As String = DirectCast(container.DataItem, DataRowView)(owner.DataField).ToString()
DDL.Items.Clear()
For Each ditem In owner.ListItems
item = New DropDownListItem(ditem.Key, ditem.Value)
item.Selected = (item.Value = selectedvalue)
DDL.Items.Add(item)
Next
End Sub
End Class
#End Region
End Class
End Namespace
I understand that you are putting efforts into this, but as I've already stated, this requirement is quite custom. Nevertheless, I value your hard work on this implementation so I will take a look to your project. For that purpose, please create a new web site sample to isolate the RadTreeList and the custom column and open a formal support ticket to send it to us.
Regards,
Eyup
Telerik
Thanks for the offer - in my attempt to isolate this into a simple website that i could upload i actually managed to get it working.
I will create the ticket anyway so you have it, and you can then choose to refine this into an example or something if you want.
I've already checked the sample and replied in the mentioned ticket.
Please feel free to turn to us for questions about the functionality provided by Telerik controls.
Regards,
Eyup
Telerik