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

RadComboBox Ajax

4 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Smiely
Top achievements
Rank 1
Smiely asked on 07 Mar 2011, 09:52 PM
Hi I have a RadTreeView(with checkboxes) in RadComboBox. I am able to display the values of selected checkboxes using label. But it's on a Button click. Ideally I wanted to display values when RadcomboBox closes.

RadComboBox1_SelectedIndexChanged is not working for me.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" >
   </telerik:RadScriptManager>
   <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
   <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadComboBox1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox1" LoadingPanelID="RadAjaxLoadingPanel1"/>
                </UpdatedControls>
            </telerik:AjaxSetting>
   </AjaxSettings>
   </telerik:RadAjaxManager>
   <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server" 
       Skin="Default" >
   </telerik:RadAjaxLoadingPanel>
   <br />
   <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    </script
    </telerik:RadCodeBlock>
            <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="250px" 
       Style="vertical-align: middle;"   
                EmptyMessage="Choose Stations..." 
         AutoPostBack="True" 
       onselectedindexchanged="RadComboBox1_SelectedIndexChanged">
                <ItemTemplate>
                    <div id="div1"  >
                        <telerik:RadTreeView runat="server" ID="RadTreeView1"   Width="100%" Height="210px" CheckBoxes="true"
                        CheckChildNodes="true" TriStateCheckBoxes="true"  >
                        </telerik:RadTreeView>
                    </div>
                </ItemTemplate>
                <Items>
                    <telerik:RadComboBoxItem Text="" />
                </Items>
            </telerik:RadComboBox>
   <br />
   <asp:Button ID="Button1" runat="server" Text="Selected Stations" 
       onclick="Button1_Click" />
     
   <p>
        </p>
   <p>
     
   <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
  
    </p>
    </form>
</body>
</html>
Please help...
Smiely

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Mar 2011, 05:53 AM
Hello Smiley,

When RadComboBox has RadTreeView as template, it actually has only one item - the templated RadTreeView. That is why the SelectedIndexChanged event of RadComboBox will not be fired.
You should subscribe to some server-side event of RadTreeView - NodeClick for example.

Hope this information helps,
Princy.
0
Smiely
Top achievements
Rank 1
answered on 08 Mar 2011, 03:40 PM
Thanks Princy for your input. I totally got what you are saying. I tried nodeClick, but when I click a node (node check in my case) the event gets fired and RadComboBox gets closed. I can not check mutiple nodes. What else can I try ???

Thanks,
Smiely
0
Smiely
Top achievements
Rank 1
answered on 08 Mar 2011, 06:08 PM
Here is the code what I tried...... NOT WORKING

ASPX:
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadComboBox1"/>
                </UpdatedControls>
</telerik:AjaxSetting>

<

 

telerik:RadComboBox ID="RadComboBox1" runat="server" Width="250px"

 

 

 

Style="vertical-align: middle;"

 

 

 

EmptyMessage="Choose Stations..."

 

 

 

OnClientDropDownOpened="OnClientDropDownOpenedHandler" AutoPostBack="True" OnClientDropDownClosed="closeDropDown">

 

JS:
function closeDropDown() {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest();
    }
CS:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            RadTreeView RadTreeView1 = (RadTreeView)RadComboBox1.Items[0].FindControl("RadTreeView1");
            ShowCheckedNodes(RadTreeView1, Label1);
        }

What am I doing wrong?

Smiely
0
Princy
Top achievements
Rank 2
answered on 09 Mar 2011, 11:34 AM
Hello Smiley,

In order to keep the dropdown open while selectind multiple nodes, a better approach is to try from the client side. Attach the OnClientDropDownClosing event to the RadComboBox and use the following code in the handler.

Java Script:
<script type="text/javascript">
    function OnClientDropDownClosing(sender, args) {
        if (args.get_domEvent().target == sender.get_imageDomElement()) {
            args.set_cancel(false);
        }
        else {
            args.set_cancel(true);
        }
    }
</script>


Thanks,
Princy.
Tags
Grid
Asked by
Smiely
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Smiely
Top achievements
Rank 1
Share this question
or