This is a migrated thread and some comments may be shown as answers.

ComboBox with EnableLoadOnDemand filtering *inner* Treeview

1 Answer 65 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Rubens
Top achievements
Rank 1
Rubens asked on 06 Apr 2011, 09:06 PM
Hi ALL,

I've a combo with treeview for department selection. I want to use combo load on demand capability to filter that treeview, so I'll display all departments which contains entered text. I managed to sign to OnItemsRequest event to search my data source and repopulate that treeview.

But, as that treeview required OnClientNodeClicking event to display department full name ("parent > parent > parent > this"), after postback this message shows up:

Script control 'hierarquia' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors(). Parameter name: scriptControl

I tried to add RegisterWithScriptManager="FALSE" on treeview and register that client event manually with no success. How should I proceed?

So far I have this code snippets (some code removed):

<telerik:RadComboBox runat="server" ID="selecao" Width="450" AutoPostBack="true"
    LoadingMessage="Loading..." EmptyMessage="Expanda a hierarquia e selecione..." 
    OnClientDropDownOpened="OnClientDropDownOpenedHandler" EnableLoadOnDemand="true"
    MinFilterLength="3" OnInit="selecao_Init" OnItemsRequested="selecao_ItemsRequested" 
    OnClientItemsRequested="OnClientItemsRequested">
    <Items>
        <telerik:RadComboBoxItem Text="" Value="0"/>
    </Items>
    <ItemTemplate>
        <telerik:RadTreeView runat="server" ID="hierarquia" Width="300" 
            RegisterWithScriptManager="FALSE" 
            OnNodeExpand="hierarquia_NodeExpand" OnNodeClick="hierarquia_NodeClick"
            OnClientNodeClicking="nodeClicking" Skin="Default" CausesValidation="false" />
    </ItemTemplate>
</telerik:RadComboBox>

        protected void selecao_Init(object sender, EventArgs e)
        {
            if (this.Hierarquia.Nodes.Count == 0)
            {
                RadTreeNodeCollection parent = this.Hierarquia.Nodes;
                // load data
             }
 
            #region ClientScriptBlock
 
            ScriptManager.RegisterClientScriptBlock(thistypeof(FiltroGenerico), "FiltroGenerico"@"
 
                function nodeClicking(sender, args) {
                    var comboBox = $find(sender._clientStateFieldID.substring(0, sender._clientStateFieldID.length - 26));
                    var node = args.get_node()
 
                    var fullname = '';  // display full treename as requested
                    var pnode = node;
                    while(pnode != null && pnode.get_text != null)
                    {
                        fullname = ' > ' + pnode.get_text() + fullname;
                        pnode = pnode.get_parent();
                    }
                    fullname = fullname.substr(3)
 
                    comboBox.set_text(fullname);
                    comboBox.trackChanges();
                    comboBox.get_items().getItem(0).set_text(fullname);
                    comboBox.commitChanges();
 
                    comboBox.hideDropDown();
                    comboBox.attachDropDown();
                }
 
                function StopPropagation(e) {
                    if (!e)  e = window.event;
                    e.cancelBubble = true;
                }
 
                function OnClientItemsRequested(sender, eventArgs) {
                    var tree = sender.get_items().getItem(0).findControl('hierarquia');
tree.add_nodeClicking(nodeClicking);
                }
 
                function OnClientDropDownOpenedHandler(sender, eventArgs) {
                    var tree = sender.get_items().getItem(0).findControl('hierarquia');
                    var selectedNode = tree.get_selectedNode();
                    if (selectedNode) {
                        selectedNode.scrollIntoView();
                    }
                }"true);
 
            #endregion
        }

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 12 Apr 2011, 01:50 PM
Hello Rubens,

You are receiving the following error since you couldn't load controls using load on demand mechanism. This is due to the fact that load on demand is causing callback not post-back to the server and thus the page life cycle is not executed. In general load on demand is used to load data not controls.

Unfortunately you won't be able to implement this scenario using RadTreeView inside RadComboBox with Load on Demand. You should either give up on the load on demand or think of another template for the RadComboBox.

All the best,
Dimitar Terziev
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.

Tags
ComboBox
Asked by
Rubens
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or