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

how to display RadGrid details of header labels without having to display master columns

1 Answer 360 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yahya
Top achievements
Rank 1
Yahya asked on 16 Jul 2016, 09:57 AM

Hello to the Telerik community!

In the attached image, I don't want to display the area circled in red but when I remove it the table says "no records to display".

<p><telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" ShowFooter="true" ShowHeader="true" RegisterWithScriptManager="false" Width="100%" Height="100%" OnNeedDataSource="RadGrid1_OnNeedDataSource" ViewStateMode="Disabled" ShowGroupPanel="true"
ClientSettings-Scrolling-AllowScroll="false" GridLines="None" AllowSorting="true" AllowMultiRowSelection="true">
 
 
  <ClientSettings>
    <Selecting AllowRowSelect="true" />
  </ClientSettings>
 
 
  <MasterTableView ShowHeadersWhenNoRecords="true">
 
 
    <NoRecordsTemplate>
      <div style="text-align: center;">
        <asp:Literal ID="NoData_lt" Text="<%$Resources:Strings,Nodatatodisplay %>:" runat="server" />
      </div>
    </NoRecordsTemplate>
 
 
    <ItemTemplate>
      <asp:Label ID="Label0" runat="server" Text="<%$ Resources:Strings, OrderReference %>" TabIndex="5" />
      <asp:Label ID="Label6" runat="server" Text='<%# Eval("TRANS_NB") %>' TabIndex="5" />
 
      <asp:Label ID="Label1" runat="server" Text="<%$ Resources:Strings, OrderAmount %>" TabIndex="5" />
      <asp:Label ID="Label7" runat="server" Text='<%# Eval("TRANS_AMOUNT") %>' TabIndex="5" />
 
      <asp:Label ID="Label2" runat="server" Text="<%$ Resources:Strings, ShippingMethod %>" TabIndex="5" />
      <%--<asp:Label ID="Label8" runat="server" Text='<%# Eval("ShippingMethod") %>' TabIndex="5" />--%>
 
      <asp:Label ID="Label3" runat="server" Text="<%$ Resources:Strings, Date %>" TabIndex="5" />
      <asp:Label ID="Label9" runat="server" Text='<%# Eval("TRANS_DATE") %>' TabIndex="5" />
 
      <asp:Label ID="Label4" runat="server" Text="<%$ Resources:Strings, BillNumber %>" TabIndex="5" />
      <asp:Label ID="Label10" runat="server" Text='<%# Eval("SHIP_BILL_NUMBER") %>' TabIndex="5" />
 
      <asp:Label ID="Label5" runat="server" Text="<%$ Resources:Strings, Shipment %>" TabIndex="5" />
      <asp:Label ID="Label11" runat="server" Text='<%# Eval("SHIP_COST") %>' TabIndex="5" />
 
    </ItemTemplate>
 
    <Columns>
      <telerik:GridBoundColumn DataField="TRANS_NB" SortExpression="TRANS_NB" HeaderText="<%$ Resources:Strings, OrderReference %>" HeaderButtonType="TextButton" />
      <telerik:GridBoundColumn DataField="TRANS_AMOUNT" SortExpression="TRANS_AMOUNT" HeaderText="<%$ Resources:Strings, OrderAmount %>" HeaderButtonType="TextButton" />
      <telerik:GridBoundColumn DataField="ShippingMethod" SortExpression="ShippingMethod" HeaderText="<%$ Resources:Strings, ShippingMethod %>" HeaderButtonType="TextButton" />
      <telerik:GridBoundColumn DataField="TRANS_DATE" SortExpression="TRANS_DATE" HeaderText="<%$ Resources:Strings, Date %>" HeaderButtonType="TextButton" />
      <telerik:GridBoundColumn DataField="SHIP_BILL_NUMBER" SortExpression="SHIP_BILL_NUMBER" HeaderText="<%$ Resources:Strings, BillNumber %>" HeaderButtonType="TextButton" />
      <telerik:GridBoundColumn DataField="SHIP_COST" SortExpression="SHIP_COST" HeaderText="<%$ Resources:Strings, Shipment %>" HeaderButtonType="TextButton" />
    </Columns>
 
 
    <DetailTables>
      <telerik:GridTableView ShowHeadersWhenNoRecords="true">
 
 
        <NoRecordsTemplate>
          <div style="text-align: center;">
            <asp:Literal ID="NoData_lt" Text="<%$Resources:Strings,Nodatatodisplay %>" runat="server" />
          </div>
        </NoRecordsTemplate>
 
 
        <Columns>
          <telerik:GridClientSelectColumn UniqueName="GridClientSelectColumn1" />
          <telerik:GridImageColumn HeaderText="<%$ Resources:Strings, Image %>" HeaderButtonType="None" />
          <telerik:GridBoundColumn DataField="PRODUCT_NAME" SortExpression="PRODUCT_NAME" HeaderText="<%$ Resources:Strings, ProductName %>" HeaderButtonType="TextButton" />
          <telerik:GridBoundColumn DataField="STORE_NAME" SortExpression="STORE_NAME" HeaderText="<%$ Resources:Strings, Supplier %>" HeaderButtonType="TextButton" />
          <telerik:GridBoundColumn DataField="PRODUCT_PRICE" SortExpression="PRODUCT_PRICE" HeaderText="<%$ Resources:Strings, UnitPrice %>" HeaderButtonType="TextButton" />
          <telerik:GridBoundColumn DataField="PRODUCT_QUANTITY" SortExpression="PRODUCT_QUANTITY" HeaderText="<%$ Resources:Strings, Quantity %>" HeaderButtonType="TextButton" />
          <telerik:GridBoundColumn DataField="TRANS_TOTAL" SortExpression="TRANS_TOTAL" HeaderText="<%$ Resources:Strings, TotalPrice %>" HeaderButtonType="TextButton" />
        </Columns>
 
 
      </telerik:GridTableView>
    </DetailTables>
 
  </MasterTableView>
</telerik:RadGrid></p><p></p>

I would like to get rid of the master table columns section and only display them as labels inside the grid. Also I'm having trouble making the table look nice, how can I TAB the labels? Do I need the TabIndex option as I'm not sure what its use is for? I can't even put ":" after Text="<%$ Resources:Strings, OrderAmount %>", as in I can't write it as Text="<%$ Resources:Strings, OrderAmount %>: " or it will only display ":" when I run the code.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 21 Jul 2016, 05:17 AM
Hi Yahya,

Can you please confirm that you have tested to set the ShowHeader property of the MasterTableView to "false" for your first requirement? You can also set the Visible property of the GridHeaderItem in the code-behind (ItemDataBound or ItemCreated events).

Regarding the item values, since you are using an item template, you should customize the look and feel within that template with CSS, as per your requirements.

Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Yahya
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or