数据表未以适当的格式显示

时间:2016-01-19 07:41:39

标签: jquery jquery-ui datatables

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

代码: -

<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();

Data table is not showing properly,please see this image

1 个答案:

答案 0 :(得分:0)

试试这个

以下是演示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,
    });
} );