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

hierarchy grid expanding

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
lina fetisova
Top achievements
Rank 1
lina fetisova asked on 29 Mar 2011, 07:01 AM
Good day!

I have got such a grid:

<telerik:RadGrid ID="grDefects" runat="server" CssClass="MyGridClass"
        AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" Skin="FarmPortal" EnableEmbeddedSkins="false"
        GridLines="None" Width="100%" PageSize="10" GroupPanel-Width="100%" OnDetailTableDataBind="DetailDataBind">

<MasterTableView TableLayout="Auto" Width="100%" EnableNoRecordsTemplate="false" NoDetailRecordsText="Нет разбракованных препаратов, привязанных к данному" HierarchyLoadMode="ServerBind">
            <DetailTables>
                <telerik:GridTableView Width="100%" ShowHeader="false" EnableNoRecordsTemplate="false" ShowFooter="false"   runat="server">
                                <Columns>
                                    <telerik:GridBoundColumn DataField="Id" HeaderText="Id" ReadOnly="True" UniqueName="Id" SortExpression="Id"  Visible="false"/>
                                    <telerik:GridBoundColumn DataField="PreparationName" HeaderText="Наименование" ReadOnly="True" UniqueName="PreparationName" SortExpression="PreparationName" />
                                    <telerik:GridBoundColumn DataField="Series" HeaderText="Серия" ReadOnly="True" UniqueName="Series" SortExpression="Series" />
                                    <telerik:GridBoundColumn DataField="DefectStatus" HeaderText="Статус" ReadOnly="True" UniqueName="DefectStatus" SortExpression="DefectStatus" />
                                </Columns>
                            </telerik:GridTableView>
            
            </DetailTables>
    <Columns>
        <telerik:GridBoundColumn DataField="Id" HeaderText="Id" ReadOnly="True" UniqueName="Id" SortExpression="Id"  Visible="false"/>
        <telerik:GridBoundColumn DataField="PreparationName" HeaderText="Наименование" ReadOnly="True" UniqueName="PreparationName" SortExpression="PreparationName" />      
        <telerik:GridBoundColumn DataField="DefectStatus" HeaderText="Статус" ReadOnly="True" UniqueName="DefectStatus" SortExpression="DefectStatus" />

    </Columns>
    <PagerStyle AlwaysVisible="true"   />
</MasterTableView>
    <ClientSettings EnableRowHoverStyle="true" AllowColumnsReorder="True" AllowDragToGroup="True" Resizing-EnableRealTimeResize="true"
        ReorderColumnsOnClient="True">
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
</telerik:RadGrid>

we build it this way

var newSource= new List<DefectWithUndefect>();
                Mapper.CreateMap<DefectDTO, DefectWithUndefect>();
                foreach (var defectDto in source.Where(s => s.ParentDefectId == 0).ToList())
                {
                    var def =Mapper.Map<DefectDTO, DefectWithUndefect>(defectDto);
                    var undefects = source.Where(s => s.ParentDefectId == defectDto.Id).ToList();
                    foreach (var undefect in undefects)
                        def.Undefects.Add(undefect);
                    newSource.Add(def);
                }
                grDefects.DataSource = newSource;

It looks like at the attached image.

So if grid element has got Undefect child, the element has got a child grid. It's a seldom situation but we can open child grid of each grid item :( What can I do to let open child grid only if child grid exists? For not to see text "no records to display"?

Thank you!
All best wishes.
Lina

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Mar 2011, 08:00 AM
Hello Lina,

One option is you can hide expand/collapse image when there is no record. The following documentation explains how to achieve this.
Hiding expand/collapse images when no records

Thanks,
Princy.
Tags
Grid
Asked by
lina fetisova
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or