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

2 posts, 0 answers
  1. Yahya
    Yahya avatar
    2 posts
    Member since:
    Jul 2016

    Posted 16 Jul 2016 Link to this post

    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">
        <Selecting AllowRowSelect="true" />
      <MasterTableView ShowHeadersWhenNoRecords="true">
          <div style="text-align: center;">
            <asp:Literal ID="NoData_lt" Text="<%$Resources:Strings,Nodatatodisplay %>:" runat="server" />
          <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" />
          <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" />
          <telerik:GridTableView ShowHeadersWhenNoRecords="true">
              <div style="text-align: center;">
                <asp:Literal ID="NoData_lt" Text="<%$Resources:Strings,Nodatatodisplay %>" runat="server" />
              <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" />

    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.
  2. Konstantin Dikov
    Konstantin Dikov avatar
    1959 posts

    Posted 21 Jul 2016 Link to this post

    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.

    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.
Back to Top