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

Style an HTML table like a radgrid

1 Answer 325 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 29 Dec 2015, 08:44 PM

I'm trying to style a table on a page like a normal RadGrid to fit with our sites theme, but I'm having trouble with it. I've copied all the styles and matched the layout I saw on the DOM for RadGrids, but the classes seem to have no effect.

Is what I'm trying to do here possible?

Here is the markup ode for the table: 

 

<div tabindex="0" class="RadGrid Radgrid_Default">
               <table  style="width:20%; margin:0 auto;" class="rgMasterTable">
                   <colgroup>
                       <col></col>
                       <col></col>
                       <col></col>
                       <col></col>
                       <col></col>
                       <col></col>
                       <col></col>
                       <col></col>
                   </colgroup>
               <thead>
                   <tr>
                       <th class="rgHeader" scope="col">Category</th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpSun" runat="server" Text="Sunday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpMon" runat="server" Text="Monday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpTues" runat="server" Text="Tuesday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpWed" runat="server" Text="Wednesday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpThurs" runat="server" Text="Thursday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpFri" runat="server" Text="Friday"></asp:label></th>
                       <th class="rgHeader" scope="col"><asp:label ID="_lblExpSat" runat="server" Text="Saturday"></asp:label></th>
                   </tr>
               </thead>
                   <tbody>
               <asp:Repeater ID="_rptExpenses" runat="server" >
                   <ItemTemplate>
                       <tr class="rgRow">
                           <td>
                               <telerik:RadDropDownList ID="_ddCategory" SelectedValue='<%# Bind("ExpenseID") %>' runat="server" DataSourceID="_srcGetCategories" DataValueField="ExpenseID" DataTextField="CategoryDesc" ExpandDirection="Up" ></telerik:RadDropDownList>
                               <asp:SqlDataSource ID="_srcGetCategories" runat="server" SelectCommand="TimeTracker.sp_getExpenseCategories" SelectCommandType="StoredProcedure" ConnectionString='<%$ ConnectionStrings:FMS_Conn %>'></asp:SqlDataSource>
                           </td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpSun" DbValue='<%# Convert.ToInt32(Eval("Sunday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpMon" DbValue='<%# Convert.ToInt32(Eval("Monday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpTues" DbValue='<%# Convert.ToInt32(Eval("Tuesday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpWed" DbValue='<%# Convert.ToInt32(Eval("Wednesday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpThurs" DbValue='<%# Convert.ToInt32(Eval("Thursday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpFri" DbValue='<%# Convert.ToInt32(Eval("Friday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                           <td>
                               <telerik:RadNumericTextBox ID="_txtExpSat" DbValue='<%# Convert.ToInt32(Eval("Saturday")) %>' runat="server" Width="50" MinValue="0" MaxValue="24" NumberFormat-DecimalDigits="1" Value="0"></telerik:RadNumericTextBox></td>
                       </tr>
                   </ItemTemplate>
               </asp:Repeater>
               <tr class="rgRow">
                   <td colspan="8" style="text-align:center">
                       <telerik:RadButton ID="_btnSubmitExpenses" runat="server" Text="Add Expense"></telerik:RadButton>
                   </td>
               </tr>
                   </tbody>
           </table>
           </div>

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 31 Dec 2015, 09:40 AM
Hello Ryan,

Usually we won't provide support for such scenarios, but here is what you can change at first glance:

1) The 'g' in RadGrid_Default should be with capital character.
<div tabindex="0" class="RadGrid RadGrid_Default">

2) To get the same look and feel, copy the inline styles of the table view:
<table  style="width:100%;table-layout:auto;empty-cells:show;" class="rgMasterTable"> ...

3) Make sure that you change between normal and alternating rows (rgRow and rgAltRow)
<tr class="rgAltRow">

Regards,
Daniel
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Ryan
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or