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

How to only display row expansion for master tables rows with 1 detail table row?

1 Answer 113 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 08 Feb 2012, 01:48 PM
Hi all,

I am attempting to create a Rad grid (version 2010.3.1215.40 in Visual Studio 2010 ) which returns a list of contacts. Each contact may have a number of 'profiles' representing how we know a person. For example, We may have a contact called Joe blogs, he could have two profiles, one which links him to Company A and one which links him to Company B (ie a contractor/consultant). A user needs to be able to select the profile id from the list of contacts, however we wish to only display the nested detail table if there is more then 1 profile. If there is only 1 profile then the user should just see that in the main grid.

So far I have the grid set up to display the full list of contacts and then they have the nested grid of profiles, however a user can currently expand a row even if it has 1 or 0 profiles. Any sugestions on how to not display the nested grid where the profile count is less then 2?

Many Thanks

<telerik:RadGrid ID="rgContactSearchResults" runat="server" Height="448px">
    <ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true" AllowKeyboardNavigation="true">
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
    <MasterTableView DataKeyNames="ContactID" AutoGenerateColumns="true" TableLayout="Fixed">
        <DetailTables>
            <telerik:GridTableView DataKeyNames="ContactID" AutoGenerateColumns="true" DataMember="ContactID">
                <ParentTableRelation>
                    <telerik:GridRelationFields DetailKeyField="ContactID" MasterKeyField="ContactID" />
                </ParentTableRelation>
            </telerik:GridTableView>
        </DetailTables>
    </MasterTableView>
</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 08 Feb 2012, 01:50 PM
Sorry, never mind. I have just found it in the documentation.

http://www.telerik.com/help/aspnet-ajax/grid-hide-expand-collapse-images-when-no-records.html

However, now all the master tables rows have their images hidden despite having a number of profiles

EDIT:

Solved. I was assigning the datasource to the detail table only when the row being expanded posted back. The count was therefore always going to be 0 (or perhaps nothing) as the preload event fired before that point . By setting the HierarchyLoadMode to Server, all the binds were then done as the gridloaded and therefore before the preload event checked the count.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Share this question
or