Problem with setting optionlist to checked state

19 posts, 0 answers
  1. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 05 Mar 2010 Link to this post

    Hi

    I have a tree view that is set to use the option list type. When I try to set a selected radio button in the code (

    item.CheckState = Automation.ToggleState.On) the chosen button does not show that it has been checked. However, when I check the state of the chosen radio button it confirms that it is in fact checked.

    Is this a known issue? Is there some other way I can make it be checked in the interface. This problem is causing alot of confusion with my customers.

    Thanks,

    Mark

  2. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 09 Mar 2010 Link to this post

    I haven't heard anything back on this problem yet.

    Just to be clear. The exact same code works as expected if I remove the ItemsOptionListType = OptionList and use the checkboxes instead. But I really want to be able to use the radio buttons.

    Thanks,

    Mark
  3. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 11 Mar 2010 Link to this post

    Hi Mark Wells,

    I couldn't reproduce your issue. The RadTreeView is behaving as expected on my side. Please take a look at the example I attached and let me know if it works for you.

    If this sample project doesn't illustrate your issue, could you please modify it so that we can further investigate.

    Please let me know if you need more info.

    Kind regards,
    Tina Stancheva
    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.
  4. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 11 Mar 2010 Link to this post

    Hi Tina,

    Thanks for the sample project. It helped me realize that I was using the Nov 09 release. I updated my project to use the newer version from January 10. This fixed the problem with setting the radio buttons to be checked.

    However, there is a new bug now with the new version.

    When you have a tree list with parent nodes that have children, the node will not appear to be clicked on the web page (although the property CheckedState does equal true).

    Below is the project that you sent me with the code changes to reproduce the issue.

    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Net;  
    using System.Windows;  
    using System.Windows.Controls;  
    using System.Windows.Documents;  
    using System.Windows.Input;  
    using System.Windows.Media;  
    using System.Windows.Media.Animation;  
    using System.Windows.Shapes;  
    using Telerik.Windows.Controls;  
     
    namespace TreeListColumns  
    {  
        public partial class MainPage : UserControl  
        {  
            public MainPage()  
            {  
                InitializeComponent();  
                BindTree();  
                SetInitialItem();  
                //tree.ItemsSource = new List<Item>{  
                //    new Item{Id="1" ,Name = "item 1"},  
                //    new Item{Id="2" ,Name = "item 1"},  
                //    new Item{Id="3" ,Name = "item 1"},  
                //    new Item{Id="4" ,Name = "item 1"},  
                //};  
            }  
     
            private void tree_SelectionChanged(object sender, Telerik.Windows.Controls.SelectionChangedEventArgs e)  
            {  
                //if (e.AddedItems != null && e.AddedItems.Count > 0)  
                //{  
                //    var treeItem = tree.ItemContainerGenerator.ContainerFromItem(e.AddedItems[0]) as RadTreeViewItem;  
                //    treeItem.CheckState = System.Windows.Automation.ToggleState.On;  
                //}  
     
                //if (e.RemovedItems != null && e.RemovedItems.Count > 0)  
                //{  
                //    var treeItem = tree.ItemContainerGenerator.ContainerFromItem(e.RemovedItems[0]) as RadTreeViewItem;  
                //    treeItem.CheckState = System.Windows.Automation.ToggleState.Off;  
                //}  
            }  
     
            private void BindTree()  
            {  
                RadTreeViewItem item1 = new RadTreeViewItem();  
                item1.Header = "Item One";  
                item1.Name = "item1";  
                item1.Tag = "item1";  
                item1.IsExpanded = true;  
                RadTreeViewItem item2 = new RadTreeViewItem();  
                item2.Header = "Item Two";  
                item2.Name = "item2";  
                item2.Tag = "item2";  
                item2.IsExpanded = true;  
                RadTreeViewItem item3 = new RadTreeViewItem();  
                item3.Header = "Item Three";  
                item3.Name = "item3";  
                item3.Tag = "item3";  
                item3.IsExpanded = true;  
                RadTreeViewItem item4 = new RadTreeViewItem();  
                item4.Header = "Item Four";  
                item4.Name = "item4";  
                item4.Tag = "item4";  
                item4.IsExpanded = true;  
                RadTreeViewItem item5 = new RadTreeViewItem();  
                item5.Header = "Item Five";  
                item5.Name = "item5";  
                item5.Tag = "item5";  
                item5.IsExpanded = true;  
     
                item4.Items.Add(item5);  
     
                tree.Items.Add(item1);  
                tree.Items.Add(item2);  
                tree.Items.Add(item3);  
                tree.Items.Add(item4);  
            }  
     
            private void SetInitialItem()  
            {  
                var itemWithNoChildren = this.tree.Items[2] as RadTreeViewItem;  
                var itemWithChildren = this.tree.Items[3] as RadTreeViewItem;  
                var childItem = itemWithChildren.Items[0] as RadTreeViewItem;  
                //This line works correctly  
                itemWithNoChildren.CheckState = System.Windows.Automation.ToggleState.On;  
                //This line sets CheckedState to true but the item is not checked on the page  
                itemWithChildren.CheckState = System.Windows.Automation.ToggleState.On;  
                //This line checks the child item as well as the parent item. This is not desirable since IsTriStateMode = false  
                childItem.CheckState = System.Windows.Automation.ToggleState.On;  
            }  
        }  
     
        public class Item  
        {  
            public string Id { getset; }  
            public string Name { getset; }  
        }  
    }  
     
     
    Let me know if you can get a hotfix to me soon. I was planning to release this Friday but I will not be able to do so using the current RadControls For Silverlight release. I would have to roll back my project to use the earlier version.

    Thanks,

    Mark
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3299 posts

    Posted 16 Mar 2010 Link to this post

    Hi Mark Wells,

    In order to set the CheckState of the RadTreeViewItems, the RadTreeView has to be loaded. Therefore, you can set the CheckState property of the RadTreeViewItems in your SetInitialItem() method after adding the following modifications:
    private void SetInitialItem()
            {
                this.Dispatcher.BeginInvoke(() =>
                    {

                        var itemWithNoChildren = this.tree.Items[2] as RadTreeViewItem;
                        var itemWithChildren = this.tree.Items[3] as RadTreeViewItem;
                        var childItem = itemWithChildren.Items[0] as RadTreeViewItem;
                        //This line works correctly  
                        itemWithNoChildren.CheckState = System.Windows.Automation.ToggleState.On;
                        //This line sets CheckedState to true but the item is not checked on the page  
                        itemWithChildren.CheckState = System.Windows.Automation.ToggleState.On;
                        //This line checks the child item as well as the parent item. This is not desirable since IsTriStateMode = false  
                            childItem.CheckState = System.Windows.Automation.ToggleState.On;
                    });
            }


    Can you please try this out and let me know if it solves your issue or if you need more info.

    Greetings,
    Tina Stancheva
    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. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 16 Mar 2010 Link to this post

    Hi Tina,

    The BeginInvoke method works on the sample project that you provided me but not on my project.

    My project is in VB so I changed the call to be Me.Dispatcher.BeginInvoke(AddressOf SetInitialItem). The method is called but checkboxes that have child nodes do not get checked. If I set the child node to be checked then that child node does get checked correctly.

    If I do not use the BeginInvoke, then I get the same results. Parents with children do not get checked but child nodes will get checked when set.

    I did not have this problem when using release 2009.3 1103 from November 3, 2009.

    Any more ideas?

    Mark
  7. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 17 Mar 2010 Link to this post

    Hi Tina,

    Ok, I found the cause of the problem with the newer release of Rad Silverlight. I downloaded the source code from December and narrowed the problem to the RadTreeView.cs.

    The solution does not need to use this.Dispatcher.BeginInvoke().

    Here is the revised code:




    /// <summary>  
            /// Updated the ckeckState of items if they are TreeViewItems.  
            /// </summary>  
            private void CalculateInitialCheckState()  
            {  
                if (this.IsOptionElementsEnabled)  
                {  
                    foreach (var item in this.Items)  
                    {  
                        var itemContainer = item as RadTreeViewItem;  
                        if (itemContainer != null)  
                        {  
                            //This line was removed since it will make the parent item CheckState = ToggleState.Off if no child items are checked   
                            //itemContainer.CheckState = RadTreeViewItem.CalculateInitialItemCheckState(itemContainer);  
     
                            //This line populates the child items correctly and leaves the parent CheckedState as it was already set to  
                            RadTreeViewItem.CalculateInitialItemCheckState(itemContainer);  
                        }  
                        else 
                        {  
                            return;  
                        }  
                    }  
                }  
            } 

    It would be helpful if this change could be incorporated in any updates that you make to the silverlight controls. I'm sure there are many developers that are creating trees in their code and they will want to allow setting of the parent node.

    I have not tested the code in any other situations that involve straight binding of the tree.

    I may actually need a full release with the fix as I am having trouble integrating the Editor dll. I have had problems with that dll before.

    Thanks,

    Mark

  8. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 18 Mar 2010 Link to this post

    Hi Again Tina,

    I have an updated code snippet that will accomplish my goals to check the parent item and retain the original developers goal to mark a parent item (that is not checked) when child items are checked. The code will be below.

    In the meantime, it has become obvious that I will need a synchronized build from you with my requested change. The January release was able to solve my problem with integrating the Editor.dll in my solution items, but the build of my revised Navigation.dll (and related projects) has been unsuccessful in synchronizing the editor.

    Any help on expediting the process of making the requested change and providing me with the resulting assemblies would be much appreciated. I have already had to put off the release for almost a week.

    Here is the suggested change:

    /// <summary>  
            /// Updated the ckeckState of items if they are TreeViewItems.  
            /// </summary>  
            private void CalculateInitialCheckState()  
            {  
                if (this.IsOptionElementsEnabled)  
                {  
                    foreach (var item in this.Items)  
                    {  
                        var itemContainer = item as RadTreeViewItem;  
                        if (itemContainer != null)  
                        {  
                            if (itemContainer.CheckState == ToggleState.On)  
                            {  
                                //Calculate child items while retaining the parent item toggle state.  
                                RadTreeViewItem.CalculateInitialItemCheckState(itemContainer);  
                            }  
                            else 
                            {  
                                //Calculate child items and mark parent item as unchecked but contains checked child items.  
                                itemContainer.CheckState = RadTreeViewItem.CalculateInitialItemCheckState(itemContainer);  
                            }  
                        }  
                        else 
                        {  
                            return;  
                        }  
                    }  
                }  
            } 

    Thanks again for your help,

    Mark
  9. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 23 Mar 2010 Link to this post

    Hi Mark Wells,

    Thank you for the detailed issue report. I am sorry that you have had to go though the source code of the controls and investigate the problem yourself.

    The fix for the problem required a few more code changes, we have implemented them and the fix will be available with the next internal build this Friday.

    I am not sure how this fits your schedule, if you want we can send you a build with the fixes earlier.

    Your Telerik Points have been updated for your feedback.

    Regards,
    Miroslav
    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.
  10. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 24 Mar 2010 Link to this post

    Hi Miroslav,

    If you could get the internal build to me sooner than Friday that would ge great. I could slip it into our Friday update.

    Thanks, again for your help,

    Mark
  11. Miroslav
    Admin
    Miroslav avatar
    922 posts

    Posted 29 Mar 2010 Link to this post

    Hello Mark Wells,

    I am sorry that I could not prepare a build for you earlier.

    Hopefully the friday's internal build will work for you.

    All the best,
    Miroslav
    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.
  12. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 29 Mar 2010 Link to this post

    I don't see Friday's internal build when I go to the silverlight internal build page
  13. Hristo
    Admin
    Hristo avatar
    408 posts

    Posted 30 Mar 2010 Link to this post

    Hi Mark Wells,

    The reason you do not see the latest internal builds is because they are related to our Q1 2010 release and you haven't downloaded it. It also appears that your license for RadControls for Silverlight has expired and you are not able to download the latest official release. Please renew your subscription and then you will be able to download Q1 2010 and will get access to the latest internal builds.

    Greetings,
    Hristo
    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.
  14. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 07 Apr 2010 Link to this post

    Hi Miroslav,

    The latest internal build did not fix the problem. I downloaded RadControls_for_Silverlight_2010_1_0402_Dev.zip

    Unfortunately, this build also broke a row being hilighted on selection in the rad grid. This worked on the Q2010 install.

    Mark
  15. Hristo
    Admin
    Hristo avatar
    408 posts

    Posted 13 Apr 2010 Link to this post

    Hello Mark Wells,

    I checked that the fix was only available in the release branch of the cotnrols. I am sorry for misleading you initially. I made sure that the change will be incldued in the next internal build as well.

    In fact I am attaching the sample with the updated assemblies.

    There was an issue with the selection which is already fixed with our latest internal build from yesterday. Please download it and give it a try. Its version is 2010.1.0412.

    Sincerely yours,
    Hristo
    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.
  16. Mark Wells
    Mark Wells avatar
    38 posts
    Member since:
    Jul 2012

    Posted 17 Apr 2010 Link to this post

    Okay, this is really pissing me off now. The problem is still not fixed and I made my company buy a new license to access the so-called fix. My company is pissed off at me and my clients are really pissed off at me..........

    You need to give me an msi with the problem fixed. I need the msi because the editor will not work unless it has been installed with the synchronized dlls.

    I am serious now. I have been screwing around with this for a month. I gave you the fix needed (an if else statement) and you have not been able to provide me with the 4 lines of code to date.

    Either give me the fix this week or give my company the money back for the new license.
  17. Hristo
    Admin
    Hristo avatar
    408 posts

    Posted 19 Apr 2010 Link to this post

    Hello Mark Wells,

    I am so sorry to hear about your frustrations while using our controls. Our local test shows that this issue is solved and it is very strange that you are still able to reproduce it. Can you send us a sample project which demonstrates the problem so we can test it locally? Also there is a newer latest internal build from Friday with version 2010.1.0416 - can you give it a try?

    As for the .msi - our Q1 2010 SP1 is due in a couple of days and you will be able to upgrade with official release. I hope this timeframe is acceptable for you.

    Please excuse us for the inconvenience caused.

    All the best,
    Hristo
    Unit Manger
    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.
  18. Muruganas
    Muruganas avatar
    4 posts
    Member since:
    Jun 2010

    Posted 27 Jul 2010 Link to this post

    HI

      I am using OPtionList in my TreeView. i want to select only one at that tree but i  am able to select more than one  Different
     group in TreeView. How to resolve this issue.
  19. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 30 Jul 2010 Link to this post

    Hi Muruganas,

    Currently the tree view places the radio buttons in each different button groups for each child list. However you can select multiple elements in the tree view. In order to allow only one item to be selected in any particular moment you must implement your own logic in the ViewModel. I'm attaching an example demonstrating that technique.

    Regards,
    Hristo Milyakov
    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
Back to Top