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

Checked State lost in Combobox

5 Answers 137 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Erik Beyer
Top achievements
Rank 1
Erik Beyer asked on 25 Nov 2010, 03:40 AM
Hi,

i am using a RadTreeview with CheckBoxes within a RadComboBox. Everything works fine, but the Combox collapses every time I Check a Node. I found a solution using the StopPropagation Function in JavaScripting preventing this behaviour, but now i am facing another problem: The Nodes I had checked are not checked anymore when submitting the form.

How can I prevent the ComboBox from collapsing AND persist the Checked States and reading them in code behind after submitting the form?

Following Code I use:

function StopPropagation(e) {
            if (!e) {
                e = window.event;
            }
 
            e.cancelBubble = true;
        }



<rad:RadComboBox ID="ddYearQuarterMonthDate" runat="server" Width="100%" Height="350px">
                                                    <ItemTemplate>
                                                        <div id="div1" onclick="StopPropagation(event);">
                                                        <rad:RadTreeView ID="radTreeViewYearQuarterMonthDate" runat="server" MultipleSelect="True" CheckBoxes="true"
                                                    TriStateCheckBoxes="false" CheckChildNodes="false" onclick="EmptyRadDatesAndRblTimespan();">
                                                        </rad:RadTreeView>
                                                        </div>
                                                    </ItemTemplate>
                                                    <Items>
                                                        <rad:RadComboBoxItem Text="" />
                                                    </Items>
                                                </rad:RadComboBox>

                               

5 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 25 Nov 2010, 10:07 AM
Hello Erik Beyer,

I'm glad you've figured out that by using the StopPropagation function you can disable the collapsing of the RadComboBox. I've created a sample project to show you RadTreeView in Combobox with checkboxes. Please note that if you ajaxify the combobox with AjaxPanel or AjaxManager - you will not be able to view the checked nodes after postback.

Please take a look at the attached .zip file and let me know if you have some questions.
 
Greetings,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jumpstart 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.
0
Erik Beyer
Top achievements
Rank 1
answered on 25 Nov 2010, 12:16 PM
Unfortunately still no success. I am using exactly your code within my page, but still are no nodes are Checked within the code behind when hitting the submit button. Its not nested in a Updatepanel. Maybe its because of the fact that I am using this whole thing within a RadWindow?
0
Erik Beyer
Top achievements
Rank 1
answered on 25 Nov 2010, 12:57 PM
... and when setting TriStateCheckBoxes="true" then everything works fine with no collapsing ComboBox, BUT: during PageLoad I check the nodes programmatically, from which the value i saved in my Session variable and they does not appear checked after page is loaded.

Here my code for checking the nodes programmatically:

ddYearQuarterMonthDate.Items.Add(new RadComboBoxItem(""));
            RadTreeNode treeParentNode = null;
            RadTreeView radTreeViewYearQuarterMonthDate = (RadTreeView)ddYearQuarterMonthDate.Items[0].FindControl("radTreeViewYearQuarterMonthDate");
            int level = 1;
 
            foreach (DataRow dr in dt.Rows)
            {
                if (Convert.ToInt16(dr["[Measures].[ParameterLevel]"]) > 0 && Convert.ToDateTime(dr["[Measures].[EntryDate]"]).Year > DateTime.Now.AddYears(-6).Year && Convert.ToDateTime(dr["[Measures].[EntryDate]"]) <= DateTime.Now)
                {
                    if (Convert.ToInt16(dr["[Measures].[ParameterLevel]"]) != level)
                    {
                        level = Convert.ToInt16(dr["[Measures].[ParameterLevel]"]);
                        treeParentNode = radTreeViewYearQuarterMonthDate.FindNodeByText(dr["[Measures].[ParameterParentCaption]"].ToString());
                    }
 
                    RadTreeNode treeChildNode = new RadTreeNode(dr["[Measures].[ParameterCaption]"].ToString(), dr["[Measures].[ParameterValue]"].ToString());
 
                    if (level == 1)
                        radTreeViewYearQuarterMonthDate.Nodes.Add(treeChildNode);
                    else
                        treeParentNode.Nodes.Add(treeChildNode);
 
                    if (SessionFacade.TimespanValue != null)
                        if (SessionFacade.TimespanValue.Contains(treeChildNode.Value))
                            treeChildNode.Checked = true;
 
                }
            }
0
Elke Kaminski
Top achievements
Rank 1
answered on 29 Nov 2010, 03:08 PM
I have the same Problem. Can you guys from the suport team please help us out?!

Thanks
Claudio
(Business Intelligence Group GmbH)
0
Veronica
Telerik team
answered on 01 Dec 2010, 09:41 AM
Hello Elke Kaminski,

Could you please open new support ticket and attach the full code so I can inspect it and help you?

Thank you!

Regards,
Veronica Milcheva
the Telerik team
Browse the vast support resources we have to jumpstart 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
TreeView
Asked by
Erik Beyer
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Erik Beyer
Top achievements
Rank 1
Elke Kaminski
Top achievements
Rank 1
Share this question
or