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):
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(this, typeof(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 }