【问题标题】:Data table is not showing in proper format数据表未以正确格式显示
【发布时间】:2016-01-19 07:41:38
【问题描述】:

在我的代码中,数据表没有以正确的格式显示。数据显示在数据表中,但表缺少边框。我附上代码和屏幕截图。请找到附件。请帮忙。

代码:-

<div style="width:90%; margin:0 auto;">
<table id="ex">
  <thead>
    <tr>
        <th>Number of accounts</th>
        <th>Number of BUs</th>
        <th>Total salesop</th>
        <th>Number of dormant accounts</th>
    </tr>
  </thead>    
</table>
    </div>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" />
     <link href="~/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>   
    <link rel="stylesheet" type="text/css" href="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/jquery.multiselect.css" />
    <link rel="stylesheet" type="text/css" href="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/assets/style.css" />
   <link rel="stylesheet" type="text/css" href="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/assets/prettify.css" />    
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" type="text/css" media="screen" />
   <link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
   <link href="//cdn.datatables.net/1.10.9/css/jquery.dataTables.min.css" rel="stylesheet" />
   <link rel="stylesheet" href="~/css/StyleSheet1.css" type="text/css" media="screen" />
   <script src="~/Scripts/jquery-1.9.1.min.js"></script>   
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script src="~/Scripts/i18n/grid.locale-en.js"></script>
    <script src="~/Scripts/jquery.jqGrid.min.js"></script> 
    <script type="text/javascript" src="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/src/jquery.multiselect.js"></script>
   <script type="text/javascript" src="http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/assets/prettify.js"></script>
   <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
<script src="//cdn.datatables.net/1.10.9/js/jquery.dataTables.min.js"></script>
    <script src="~/Scripts/fourth_page.js"></script>

jquery:-

$('#ex').dataTable({

                    "aaData": data,
                    "aoColumns": [{ "mData": "FirstNamecount" },
                        { "mData": "LastNamecount" },
                        { "mData": "Salary" },
                        { "mData": "Gendercount" }],
                    retrieve: true,
                    "bDestroy": true,
                    paging: false,

                }).fnDestroy();

【问题讨论】:

    标签: jquery jquery-ui datatables


    【解决方案1】:

    试试这个

    这里是演示https://jsfiddle.net/tenigada/5hj276ej/2/

    HTML

    <div style="width:90%; margin:0 auto;">
    <table id="example"  class="cell-border" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <th>Name</th>
                    <th>Position</th>
                    <th>Office</th>
                    <th>Age</th>
                    <th>Start date</th>
                    <th>Salary</th>
                </tr>
            </tfoot>
            <tbody>
                <tr>
                    <td>Tiger Nixon</td>
                    <td>System Architect</td>
                    <td>Edinburgh</td>
                    <td>61</td>
                    <td>2011/04/25</td>
                    <td>$320,800</td>
                </tr>
                <tr>
                    <td>Garrett Winters</td>
                    <td>Accountant</td>
                    <td>Tokyo</td>
                    <td>63</td>
                    <td>2011/07/25</td>
                    <td>$170,750</td>
                </tr>
                 </tbody>
        </table>
        </div>
    

    JS 代码

    jQuery(document).ready(function() {
    
        jQuery('#example').DataTable({
    
         "paging": false,
         // "retrieve": true
         "bDestroy": true,
        });
    } );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-30
      • 2019-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      相关资源
      最近更新 更多