RadComboBox RadTreeView ServerSide

8 posts, 0 answers
  1. Cristian Malinescu
    Cristian Malinescu avatar
    13 posts
    Member since:
    May 2010

    Posted 03 May 2010 Link to this post

    Hi

    I'm trying to insert in the server side the nodes of a treeview as in the sample 

    http://demos.telerik.com/aspnet-ajax/treeview/examples/functionality/treeviewcombobox/defaultcs.aspx

    but my code fails as there is no treeview widget object available  

    aspx code:

     

    <td align = "left">

     

     

     

      <telerik:RadComboBox id = "_Fields_ComboBox_" EmptyMessage = "Choose a field..." runat = "server">

     

     

     

        <ItemTemplate>

     

     

     

           <div id = "_Fields_TreeView_Container_">

     

     

     

             <telerik:RadTreeView id = "_Fields_TreeView_" runat = "server">
    ...

    and VB

     

    Dim

     

    ref As Object = _Fields_ComboBox_.Items(0).FindControl("_Fields_TreeView_")

     

     

     

    will generate

    [ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index]
       System.Collections.ArrayList.get_Item(Int32 index) +7487944
       System.Web.UI.StateManagedCollection.System.Collections.IList.get_Item(Int32 index) +12
       Telerik.Web.UI.ControlItemCollection.get_Item(Int32 index) +48
       Telerik.Web.UI.RadComboBoxItemCollection.get_Item(Int32 index) +36


    It looks to me like a candiate for a bug ...?
    I use a lot in the server to fill treeview widgets with nodes with no problems; this is the single case where I try to do the same
    in a treeview wrapped as an itemtemplate for a combobox.

    The provided sample is not covering this scenario; maybe will be a good idea to add it.

    Cheers,
    Cris

    Update:

    I removed the server side code and I put for testing a declarative list of nodes in the <Nodes/> section - as per example;
    my combo dosn't display any of these items - it is always empty.  The RadControls version we use is Q1 2010.
     

     

  2. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 04 May 2010 Link to this post

    Hello Cristian Malinescu,

    I made a test project to test your scenario.

    After you add the RadTreeView as an ItemTemplate in your RadComboBox I can not see but I think you are missing an Item in your RadComboBox:

    <telerik:RadComboBox ID="RadComboBox1" runat="server" Height="140px" Width="215px"
                    ShowToggleImage="True" Style="vertical-align: middle;" OnClientDropDownOpened="OnClientDropDownOpenedHandler"
                    EmptyMessage="Choose a destination" ExpandAnimation-Type="None" CollapseAnimation-Type="None">
                    <ItemTemplate>
                        <div id="div1">
                            <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking" Height="138px" Width="212px">
                            </telerik:RadTreeView>
                        </div>
                    </ItemTemplate>
                    <Items>
                        <telerik:RadComboBoxItem Text="" />
                    </Items>
                </telerik:RadComboBox>

    This will cause an ArgumentOutOfRangeException when you try to index the Items of the RadComboBox as this:

    Dim tree As RadTreeView = DirectCast(RadComboBox1.Items(0).FindControl("RadTreeView1"), RadTreeView)

    Find my project in the attached .zip file and please let me know if this was helpful.

    Regards,
    Veronica Milcheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cristian Malinescu
    Cristian Malinescu avatar
    13 posts
    Member since:
    May 2010

    Posted 04 May 2010 Link to this post

    Thank you Veronica,

    It is right; all my items are server side dynamically created; the same technique works without problems for a not combobox embedded treeview; like this:

    aspx:

     

    <telerik:RadComboBox id = "_Employee_ComboBox_"

     

     

    EmptyMessage = "Choose an employee..."

     

     

    runat = "server">

     

     

    </telerik:RadComboBox>

     


    code-behind:

    Dim

     

    comboBoxItem As RadComboBoxItem

     

     

    For Each employee As Employee In employees

     

    comboBoxItem =

    New RadComboBoxItem()

     

    comboBoxItem.Text = employee.LastName &

    ", " & employee.FirstName

     

    comboBoxItem.Value =

    CType(employee.ID, String)

     

    _Employee_ComboBox_.Items.Add(comboBoxItem)

     

    Next

     


    So, what I think the code flow of the combobox embedded treeview *forgets* (leaves undefined) about the parent/child widgets relationship; this is a bug. Debugging I see that the items collection of the combobox is empty.
  5. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 07 May 2010 Link to this post

    Hello Cristian Malinescu,

    Could you please send me the full code you are using so we can be able to help you?

    Thank you!

    Greetings,
    Veronica Milcheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Cristian Malinescu
    Cristian Malinescu avatar
    13 posts
    Member since:
    May 2010

    Posted 07 May 2010 Link to this post

    Hi Veronica and thanks for the assistance.

    The code we talked about is not so much relevant as I got the working internals of the radcombo/radtree partnership; the tree widget is expected to be a context provider(value/text) for the default - on purpose declared empty item of the combo widget.

    The problem I'm facing now is this one, can you help with it?

    http://www.telerik.com/community/forums/aspnet-ajax/combobox/radcombobox-radtreeview-item-server-side-the-combobox-doesn-t-resize-when-tree-expands.aspx

    Also, as a suggestion - I think there is still work to be done for the combo/tree integration as the scenario presented in the sample
    looks to me as more suited to pure declarative scenarios - for cases when the whole content is dynamic I think lots of work has to be done on the sides - in the browser to resize the radcombo so that no scrolling would be required from the user perspective.

    Cheers,
    Cris
  7. Veronica
    Admin
    Veronica avatar
    1213 posts

    Posted 13 May 2010 Link to this post

    Hi Cristian Malinescu,

    To be able to resize the RadComboBox and no H/V scrollbars to appear you may subscribe to the OnClientNodeExpanding event like this:

    function nodeExpanding(sender, eventArgs) {
                var $ = $telerik.$;
                var combo = $find("<%= RadComboBox1.ClientID %>");
                var dropDownElement = combo.get_dropDownElement();
                var treeDiv = document.getElementById("RadComboBox1_i0_RadTreeView1");
                $(".rcbScroll", dropDownElement).height(treeDiv.style.height);
            }

    In the function above we are getting the height of the div tag which contains the RadTreeView. After that we are setting the height of the RadComboBox to this height.

    Find the full code in the attached .zip file.

    Hope this helps. 
     
    Sincerely yours,
    Veronica Milcheva
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  8. Prahlad
    Prahlad avatar
    3 posts
    Member since:
    Mar 2015

    Posted 10 Mar 2015 Link to this post

    hii,

    I am trying to find my treeview contol

     Telerik.Web.UI.RadTreeView treeView = (Telerik.Web.UI.RadTreeView)rcbParent.Items[0].FindControl("rtvParent");
     then i am getting error
    Object reference not set to an instance of an object.

    please help me to solve this...
    thanks in Advance
  9. Ivan Danchev
    Admin
    Ivan Danchev avatar
    834 posts

    Posted 12 Mar 2015 Link to this post

    Hello,

    Can you please elaborate more on what controls you have on your page and if they are nested what is the hierarchy? It would be helpful if you could post the content of your .aspx file, which would give us an idea which control you are trying to access.

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

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