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
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