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

Grid - ListView/DataList View with telerik:GridTableView

1 Answer 31 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Quoc
Top achievements
Rank 1
Quoc asked on 01 Nov 2013, 08:12 AM
I try to make like this example http://demos.telerik.com/aspnet-ajax/grid/examples/programming/listview/defaultcs.aspx

My problem is it not  <telerik:RadGrid> but it is
 <telerik:GridTableView>

Problem in here ...
<ItemTemplate>
                     <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %>
                      <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>'
                    runat="server">
                      <asp:Image runat="server" style="float:left" Width="200px" Height="200px" ImageUrl='<%# Eval("Url")%>' />
                        </asp:Panel>
                       </ItemTemplate>

This is my full code:
<body>
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="QsfSkinManager" runat="server" ShowChooser="true" />
    <telerik:RadFormDecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
        EnableRoundedCorners="false" />
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <ajaxsettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"></telerik:AjaxUpdatedControl>
                </UpdatedControls>
            </telerik:AjaxSetting>
        </ajaxsettings>
    </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" Width="95%"
        AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowPaging="True"
        GridLines="None" ShowStatusBar="true">
        <mastertableview datasourceid="SqlDataSource1" datakeynames="Id" allowmulticolumnsorting="True"
            width="100%">
            <Columns>
                <telerik:GridBoundColumn DataField="TT_TenMauVat" HeaderText="Tên mẫu vật" SortExpression="TenMauVat"
                    FilterDelay="1000" HeaderStyle-Width="200px" UniqueName="TenMauVat" CurrentFilterFunction="Contains"
                    ShowFilterIcon="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TT_SoHieuMauVat" HeaderText="Số hiệu mẫu vật"
                    SortExpression="SoHieuMauVat" FilterDelay="1000" HeaderStyle-Width="200px" UniqueName="SoHieuMauVat"
                    CurrentFilterFunction="StartsWith" ShowFilterIcon="false">
                </telerik:GridBoundColumn>
            </Columns>
            <DetailTables>
                <telerik:GridTableView AutoGenerateColumns="false" AllowSorting="false" DataSourceID="SqlDataSource2"
                    Width="100%" ShowHeader="false" PageSize="7">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="Id" MasterKeyField="Id"></telerik:GridRelationFields>
                    </ParentTableRelation>
                    <Columns>
                        <telerik:GridBoundColumn DataField="TT_TenMauVat" HeaderText="Tên mẫu vật" SortExpression="TenMauVat"
                            FilterDelay="1000" HeaderStyle-Width="200px" UniqueName="TenMauVat" CurrentFilterFunction="Contains"
                            ShowFilterIcon="false">
                        </telerik:GridBoundColumn>
                    </Columns>
                    <ItemTemplate>
                        <fieldset style="padding: 10px;">
                            <legend style="padding: 5px;"><b>Thông tin chi ti?t c?a m?u v?t:   <%#Eval("TT_TenMauVat")%></b>
                            </legend>
                            <table>
                                <tbody>
                                    <tr>
                                        <td>
                                            <table>
                                                <tbody>
                                                    <tr>
                                                        <td>
                                                            S? hi?u m?u v?t:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="cityLabel" Text='<%#Bind("TT_SoHieuMauVat") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Tên m?u v?t:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label2" Text='<%#Bind("TT_TenMauVat") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Noi luu tr? hi?n t?i:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label3" Text='<%#Bind("TT_NoiLuuGiuHienTai") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Phuong th?c th?i di?m giao:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label4" Text='<%#Bind("TT_PhuongThucThoiDiemGiao") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            S? lu?ng:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label5" Text='<%#Bind("TT_SoLuong") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            S? hi?u b?o tàng:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label6" Text='<%#Bind("TT_SoHieuBaoTang") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Ð? b?o m?t:
                                                        </td>
                                                        <td>
                                                            <asp:Label ID="Label7" Text='<%#Bind("TT_DoBaoMat") %>' runat="server"></asp:Label>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                        <td>
                                            <img width="200px" height="200px" src='<%#Eval("TT_HinhDaiDien")%>' alt="Hình d?i di?n" />
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </fieldset>
                    </ItemTemplate>
                </telerik:GridTableView>
                 
                
     
     
               <telerik:GridTableView AllowSorting="false" AutoGenerateColumns="false" ShowHeader="false" OnPreRender="RadGrid3_PreRender"
                    DataSourceID="SqlDataSource3" Width="100%">
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="Id" MasterKeyField="Id"></telerik:GridRelationFields>
                    </ParentTableRelation>
                     <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                    <Columns>
                        <telerik:GridImageColumn DataType="System.String" DataImageUrlFields="Url" Visible="false" AlternateText="Customer image"
                            DataAlternateTextField="Url" ImageAlign="Middle" ImageHeight="110px" ImageWidth="90px"
                            HeaderText="Image Column" FooterText="ImageColumn footer">
                        </telerik:GridImageColumn>
                    </Columns>
                     
                      <ItemTemplate>
                     <%# (((GridItem)Container).ItemIndex != 0)? "</td></tr></table>" : "" %>
                      <asp:Panel ID="ItemContainer" CssClass='<%# (((GridItem)Container).ItemType == GridItemType.Item)? "item" : "alternatingItem" %>'
                    runat="server">
                      <asp:Image runat="server" style="float:left" Width="200px" Height="200px" ImageUrl='<%# Eval("Url")%>' />
                        </asp:Panel>
                       </ItemTemplate>
                </telerik:GridTableView>
                 
                 
            </DetailTables>
        </mastertableview>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:CoVatConnectionString %>"
        SelectCommand="SELECT * FROM [MauVat]" runat="server"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:CoVatConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [MauVat] where Id=@Id"
        runat="server">
        <SelectParameters>
            <asp:Parameter Name="Id" Type="string"></asp:Parameter>
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:CoVatConnectionString %>"
        ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [MauVatImage] where MauVatId=@Id "
        runat="server">
        <SelectParameters>
            <asp:Parameter Name="Id" Type="string"></asp:Parameter>
        </SelectParameters>
    </asp:SqlDataSource>
</body>


Could you help me ? thanks 

1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 06 Nov 2013, 07:05 AM
Hi Quoc,

Generally the functionality described is not supported for scenarios where a hierarchical grid is used. That said you can use a NestedViewTemplate instead and place a ListView inside it. Additionally if you still want to use a RadGrid you can replace the ListView with it.

Regards,
Angel Petrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Quoc
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or