Radfilter with ardcombo and radtreeview issue in vb.net

5 posts, 0 answers
  1. Warn
    Warn avatar
    6 posts
    Member since:
    Apr 2011

    Posted 21 Apr 2011 Link to this post

    Hi,

    I am using the Radfilter in my vb.net(2008) project.I am using the RadTreeview as the radcomboboxItem in the datafield editor.I mange to build the control dynamically.But when I add new rows for the filter,previously selected value is set to empty.

    Please help on this issue..
    Public Overrides Sub InitializeEditor(ByVal container As System.Web.UI.Control)
            _combo = New RadComboBox()
            _combo.ID = "MyCombo"
            _combo.Width = 200
            _combo.Height = 180
      
      
            'For the Treeview
            Dim treeItem As New ItemTemplateTreeView(CreateDataSource())
            _combo.ItemTemplate = treeItem
            Dim item As New RadComboBoxItem()
            _combo.Items.Add(item)
            _combo.OnClientDropDownOpened = "OnClientDropDownOpenedHandler"
                   container.Controls.Add(_combo)
      
        End Sub
      
      
    Public Overrides Function ExtractValues() As System.Collections.ArrayList
            Dim list As ArrayList = New ArrayList()
            list.Add(DirectCast(_combo.Items(0).FindControl("myTreeview"), RadTreeView).SelectedValue)
            Return list
        End Function
      
    Public Overrides Sub SetEditorValues(ByVal values As System.Collections.ArrayList)
              
            If Not values Is Nothing And values.Count > 0 Then
                If values(0) Is Nothing Then
                    Return
                End If
                'Dim item As RadComboBoxItem = _combo.FindItemByValue(values(0).ToString())
                Dim item As RadTreeNode = DirectCast(_combo.Items(0).FindControl("myTreeview"), RadTreeView).FindNodeByValue(values(0).ToString())
                'If Not item Is Nothing Then
                    item.Selected = True
                    _combo.Items(0).Text = item.Text
                '   _combo.Items(0).Value = item.Value
                End If
                 
            End If
        End Sub
      
    Protected Function CreateDataSource() As DataTable
            Dim dataTable As New DataTable()
            dataTable.Columns.Add(New DataColumn("Key", GetType(String)))
            dataTable.Columns.Add(New DataColumn("Name", GetType(String)))
            dataTable.Columns.Add(New DataColumn("ParentId", GetType(String)))
      
            Dim AnalysItems As AnalysListItemList = TryCast(DataSource, AnalysListItemList )
      
            For Each item As CategoryValueListItem In AnalysItems
                Dim dr As DataRow = dataTable.NewRow()
                dr("Key") = item.Key
                dr("Name") = item.Name
                If item.Category = item.Key Then
                    dr("ParentId") = DBNull.Value
                Else
                    dr("ParentId") = item.Category            End If
                dataTable.Rows.Add(dr)
            Next
            Return dataTable
        End Function
      
    Public Class ItemTemplateTreeView
        Implements ITemplate
      
        Private dataTable As DataTable
        Public Sub New(ByVal _dataTable As DataTable)
            '
            ' TODO: Add constructor logic here
            '
            Me.dataTable = _dataTable
        End Sub
        Public Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn
            Dim div As New HtmlGenericControl("div")
            div.ID = "div1"
            div.Attributes.Add("onclick", "StopPropagation(event);")
      
            Dim tree As New RadTreeView()
            Dim item As RadComboBoxItem = DirectCast(container, RadComboBoxItem)
      
            tree.ID = "myTreeView"
            tree.OnClientNodeClicking = "nodeClicking"
            tree.DataTextField = "Name"
            tree.DataFieldID = "Key"
            tree.DataValueField = "Key"
            tree.DataFieldParentID = "ParentId"
            tree.DataSource = dataTable
            tree.DataBind()
      
            div.Controls.Add(tree)
            container.Controls.Add(div)
      
      
        End Sub
      
    End Class
  2. Warn
    Warn avatar
    6 posts
    Member since:
    Apr 2011

    Posted 26 Apr 2011 Link to this post

    Hi Telerik Team,

    Please support on this issue.....

    Thanks
    Warn
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 27 Apr 2011 Link to this post

    Hello Warn,

    Could you please try selecting the RadTreeView's item on _combo.DataBound event instead directly into the SetEditorValues function and let me know if the issue still exists. For example:
    Dim vals As System.Collections.ArrayList = new System.Collections.ArrayList()
    Public
    Overrides Sub SetEditorValues(ByVal values As System.Collections.ArrayList)
            vals = values
            If Not values Is Nothing And values.Count > 0 Then
                If values(0) Is Nothing Then
                    Return
                End If
     
                AddHandler _combo.DataBound, AddressOf combo_DataBound
     
            End If
     
            End If
        End Sub
       
        Protected Sub combo_DataBound(ByVal sender As Object, ByVal e As EventArgs)
            Dim _combo As RadComboBox = DirectCast(sender, RadComboBox)
            Dim item As RadTreeNode = DirectCast(_combo.Items(0).FindControl("myTreeview"), RadTreeView).FindNodeByValue(vals(0).ToString())
            'If Not item Is Nothing Then
            item.Selected = True
            _combo.Items(0).Text = item.Text
        End Sub

    Looking forward for your reply.

    Regards,
    Radoslav
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Warn
    Warn avatar
    6 posts
    Member since:
    Apr 2011

    Posted 27 Apr 2011 Link to this post

    Hi Radoslav,

    Thanks for your prompt response.Still the same issue :(

    I did some changes and now when I add more than one filter rows,the previous selected values are displaying.My current issue is that when I submit the page and if I click the browser back button, the lastly selected filter value (dropdown item is showing) is passing as empty string in the Arraylist which is in the "ExtractValues()" function.
    The empty string issue is only for the last filter value if I do the page back button from the browser.

    Please help.
  6. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 29 Apr 2011 Link to this post

    Hello Warn,

    Could you please post your aspx markup code with the related code behind file. Thus we will be able to gather more details about your scenario and provide you with more to-the-point answer.

    Looking forward for your reply.

    Greetings,
    Radoslav
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017