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

RadGrid Hiding Expand when no records are available problems

2 Answers 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
IT
Top achievements
Rank 1
IT asked on 28 Jan 2009, 11:11 AM
HI all

I'm following the example available here

http://www.telerik.com/help/aspnet-ajax/grdhideexpandcollapseimageswhennorecords.html

The problem is that when i test on my page it doesnt quite work in the way i am expecting

My grid is initially filtered by a dropdown combo box (RadCombo actually ) therefore a postback is required.


When i change options in the drop down the grid is shown with all expand images showing

If i select any expand images the grid refreshes but this time hides all the expand images apart from the ones which actually have detail records.

How can i modify this so that when the grid is refreshed based on a selection from the combo box , i get the response i 'm having (i.e hiding the expand buttons when no detail records are available)

Thanks again folks


so my code is the following

   protected void RadGridRelatedStyles_PreRender(object sender, EventArgs e) 
    { 
 
 
            HideExpandColumnRecursive(RadGridRelatedStyles.MasterTableView); 
         
    } 
    public void HideExpandColumnRecursive(GridTableView tableView) 
    { 
        GridItem[] nestedViewItems = tableView.GetItems(GridItemType.NestedView); 
        foreach (GridNestedViewItem nestedViewItem in nestedViewItems) 
        { 
            foreach (GridTableView nestedView in nestedViewItem.NestedTableViews) 
            { 
                if (nestedView.Items.Count == 0) 
                { 
                    TableCell cell = nestedView.ParentItem["ExpandColumn"]; 
                    cell.Controls[0].Visible = false
                    nestedViewItem.Visible = false
                } 
                if (nestedView.HasDetailTables) 
                { 
                    HideExpandColumnRecursive(nestedView); 
                } 
            } 
        } 
    } 
    protected void RadComboBStyles_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        HideExpandColumnRecursive(RadGridRelatedStyles.MasterTableView); 
 
    } 
and the main settings for the grid are

<telerik:RadGrid ID="RadGridRelatedStyles" OnPreRender="RadGridRelatedStyles_PreRender" runat="server" AutoGenerateColumns="False" 
        DataSourceID="SqlGroupStyle" GridLines="None" Skin="Gray" Width="250px" PageSize="8"
        <HeaderContextMenu EnableTheming="True" Skin="Gray"
            <CollapseAnimation Duration="200" Type="OutQuint" /> 
        </HeaderContextMenu> 
        <MasterTableView Caption="Related Group Styles" DataKeyNames="StyleTypeID" 
         HierarchyLoadMode="ServerBind" DataSourceID="SqlGroupStyle"  
         NoMasterRecordsText="No Available Group Styles"


Thanks guys/Gals









2 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 02 Feb 2009, 08:13 AM
Hello Brian,

Can you please set the hierarchyLoadMode to client, and see if the images are hidden as expected?

Sincerely yours,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
IT
Top achievements
Rank 1
answered on 02 Feb 2009, 03:52 PM
wow as simple as that

Thanks alot

Tags
Grid
Asked by
IT
Top achievements
Rank 1
Answers by
Yavor
Telerik team
IT
Top achievements
Rank 1
Share this question
or