update group checkbox when Data item checkbox are selected

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    3 posts
    Member since:
    Dec 2015

    Posted 21 Dec 2015 Link to this post

    I have a grid with a that I dynamically created a checkbox on the Group Header. I am trying to toggle the checkboxes in the data item to check or uncheck the group checkbox. The code below is selecting the Header checkbox and not the group checkbox. How can I acheive this?

    protected void ToggleRowSelection(object sender, EventArgs e)
            {
                ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
                bool checkHeader = true;
                    foreach (GridDataItem dataItem in rgvFunctions.MasterTableView.Items)
                    {
                        if (!(dataItem.FindControl("isFunction") as CheckBox).Checked)
                        {
                            checkHeader = false;
                            break;
                        }
                    }
                   
           
                GridHeaderItem headerItem = rgvFunctions.MasterTableView.GetItems(GridItemType.Header)[0] as GridHeaderItem;
                (headerItem.FindControl("CheckAll") as CheckBox).Checked = checkHeader;
               
            }

  2. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 24 Dec 2015 Link to this post

    Hello Andrew,

    This requirement is not supported out of the box. You can try to implement some kind of custom jQuery solution using CSS classes or other indication or log it as a feature request in our improvements portal and our dev team may consider implementing it for the future releases:
    http://feedback.telerik.com/Project/108


    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andrew
    Andrew avatar
    3 posts
    Member since:
    Dec 2015

    Posted 24 Dec 2015 Link to this post

    I found the solution. I first find the GroupHeader and iterate through the child 

     

    protected void ToggleRowSelection(object sender, EventArgs e)
            {
                ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
                bool checkHeader = true;
                foreach (GridGroupHeaderItem headerItem in rgvFunctions.MasterTableView.GetItems(GridItemType.GroupHeader))
                {
                    checkHeader = true;
                    GridItem[] children = headerItem.GetChildItems();
                    foreach (GridItem child in children)
                    {
                        if (!(child.FindControl("isFunction") as CheckBox).Checked)
                        {
                            checkHeader = false;
                            break;
                        }
                    }

                    var checkbox = headerItem.FindControl("CheckAll") as CheckBox;
                       checkbox.Checked = checkHeader;
                }
            }

  5. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 25 Dec 2015 Link to this post

    Hello Andrew,

    Thank you for sharing your specific approach with our community. I hope it may prove helpful to other developers as well.

    Regards,
    Eyup
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top