Change expand collapse image of radgrid on the fly

2 posts, 0 answers
  1. Tiago
    Tiago avatar
    3 posts
    Member since:
    Dec 2017

    Posted 21 Sep 2018 Link to this post

    Hi there, 

    I am trying to change the expand/collapse of the radgrid on the fly. The reason is because I wanna change the icon when I do not have any item on the detail table for the respective Item, working as a visual cue.

    Following is my code:


    GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView);
                foreach (GridNestedViewItem nestedViewItem in nestedViewItems)
                    foreach (GridTableView nestedView in nestedViewItem.NestedTableViews)
                        if (**myBusinessLogic**)
                            nestedView.ExpandCollapseColumn.ButtonType = GridExpandColumnType.ImageButton;
                            nestedView.ExpandCollapseColumn.ExpandImageUrl = "../Resource/Image/CustomExpand.png";
                            nestedView.ExpandCollapseColumn.CollapseImageUrl = "../Resource/Image/CustomCollapse.png";


    After running this code the icon remains the same. 

    Thank you


  2. Eyup
    Eyup avatar
    4046 posts

    Posted 26 Sep 2018 Link to this post

    Hello Tiago,

    You can use the following approach to achieve this requirement:

    Here are some key points:
    1. Change the HierarchyLoadMode to either ServerBind or Client
    2. Change the button type of the expand column to ImageButton:
    <telerik:RadGrid ... MasterTableView-ExpandCollapseColumn-ButtonType="ImageButton">
    3. Access the ImageButton when there are no child records using the approach demonstrate in the article given above, and change its ImageUrl property depending on your requirements.

    I hope this will prove helpful.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top