Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如何使用jQuery数据表插件?_Asp.net Mvc_Asp.net Mvc 4_Datatable_Bootstrap 4 - Fatal编程技术网

Asp.net mvc 如何使用jQuery数据表插件?

Asp.net mvc 如何使用jQuery数据表插件?,asp.net-mvc,asp.net-mvc-4,datatable,bootstrap-4,Asp.net Mvc,Asp.net Mvc 4,Datatable,Bootstrap 4,我的问题是,如果我使用另一种类型的表,我不能最小化“Recursos Humanos”和“Nominas”,例如,如果您最小化它,则响应 这是使用:datatable responsive 好的,这是我使用cdn的代码: <table id="employeeTable" class="display nowrap" style="width:100%"> <thead> <tr> <th>Name

我的问题是,如果我使用另一种类型的表,我不能最小化“Recursos Humanos”和“Nominas”,例如,如果您最小化它,则响应

这是使用:datatable responsive

好的,这是我使用cdn的代码:

<table id="employeeTable" class="display nowrap" style="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>
    <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>
        <tr>
            <td>Ashton Cox</td>
            <td>Junior Technical Author</td>
            <td>San Francisco</td>
            <td>66</td>
            <td>2009/01/12</td>
            <td>$86,000</td>
        </tr>
        <tr>
            <td>Zorita Serrano</td>
            <td>Software Engineer</td>
            <td>San Francisco</td>
            <td>56</td>
            <td>2012/06/01</td>
            <td>$115,000</td>
        </tr>
        <tr>
            <td>Jennifer Acosta</td>
            <td>Junior Javascript Developer</td>
            <td>Edinburgh</td>
            <td>43</td>
            <td>2013/02/01</td>
            <td>$75,650</td>
        </tr>
        <tr>
            <td>Cara Stevens</td>
            <td>Sales Assistant</td>
            <td>New York</td>
            <td>46</td>
            <td>2011/12/06</td>
            <td>$145,600</td>
        </tr>
        <tr>
            <td>Hermione Butler</td>
            <td>Regional Director</td>
            <td>London</td>
            <td>47</td>
            <td>2011/03/21</td>
            <td>$356,250</td>
        </tr>
        <tr>
            <td>Lael Greer</td>
            <td>Systems Administrator</td>
            <td>London</td>
            <td>21</td>
            <td>2009/02/27</td>
            <td>$103,500</td>
        </tr>
        <tr>
            <td>Jonas Alexander</td>
            <td>Developer</td>
            <td>San Francisco</td>
            <td>30</td>
            <td>2010/07/14</td>
            <td>$86,500</td>
        </tr>
        <tr>
            <td>Shad Decker</td>
            <td>Regional Director</td>
            <td>Edinburgh</td>
            <td>51</td>
            <td>2008/11/13</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>Michael Bruce</td>
            <td>Javascript Developer</td>
            <td>Singapore</td>
            <td>29</td>
            <td>2011/06/27</td>
            <td>$183,000</td>
        </tr>
        <tr>
            <td>Donna Snider</td>
            <td>Customer Support</td>
            <td>New York</td>
            <td>27</td>
            <td>2011/01/25</td>
            <td>$112,000</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>
</table>


<link href="https://cdn.datatables.net/1.10.12/css/jquery.dataTables.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/buttons/1.2.2/css/buttons.dataTables.css" rel="stylesheet" />
<link herf="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" rel="stylesheet" />


@section scripts{


<script src="https://code.jquery.com/jquery-1.12.4.js"></script> @**@
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.4.2/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.4.2/js/buttons.html5.min.js"></script>

<script>
        $(document).ready(function () {
            $('#employeeTable').DataTable({
                "scrollX": true,
                dom: 'Bfrtip',
                buttons: [ {
                    extend: 'excel',
                    title: 'ALIMENTOS DE CORTES:' + 'Planilla Produccion' ,
                    filename: 'PLANILLA PRODUCCION',
                    text: '<i class="fa fa-file-excel-o"></i> Excel'
                }]
            });
        });
</script>
}

名称
位置
办公室
年龄
开始日期
薪水
老虎尼克松
系统架构师
爱丁堡
61
2011/04/25
$320,800
加勒特温特斯
会计
东京
63
2011/07/25
$170,750
阿什顿考克斯
初级技术作者
旧金山
66
2009/01/12
$86,000
佐丽塔·塞拉诺
软件工程师
旧金山
56
2012/06/01
$115,000
詹妮弗·阿科斯塔
初级Javascript开发人员
爱丁堡
43
2013/02/01
$75,650
卡拉·史蒂文斯
营业员
纽约
46
2011/12/06
$145,600
赫敏·巴特勒
区域主任
伦敦
47
2011/03/21
$356,250
拉尔·格里尔
系统管理员
伦敦
21
2009/02/27
$103,500
乔纳斯·亚历山大
开发商
旧金山
30
2010/07/14
$86,500
鲱鱼
区域主任
爱丁堡
51
2008/11/13
$183,000
迈克尔·布鲁斯
Javascript开发人员
新加坡
29
2011/06/27
$183,000
唐娜·斯奈德
客户支持
纽约
27
2011/01/25
$112,000
名称
位置
办公室
年龄
开始日期
薪水
@节脚本{
@**@
$(文档).ready(函数(){
$(“#employeeTable”).DataTable({
“scrollX”:正确,
dom:'Bfrtip',
按钮:[{
扩展:“excel”,
标题:'ALIMENTOS DE CORTES:'+'Planilla Produccion',
文件名:“PLANILLA PRODUCCION”,
文本:“Excel”
}]
});
});
}

从Datatables.net下载所需的依赖项,如js文件和css文件

使用CDN链接

CDN链接包括:

CSS

<link rel="stylesheet" href="cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
//如果是下载的文件

最佳做法是将所有依赖项包含在
App\u Start/BundleConfig.cs
文件中。然后在
Global.asax
文件中注册所有捆绑包

并从
\u Layout.cshtml
中的
Bundle.Config
文件访问所有脚本和CSS,如下所示:

@section scripts {
    <script type="text/javascript" src="cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    //..
}
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")   // in the jquery bundle the the datatables files are included there.
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
有一件事非常重要。。。当从
\u Layout.cshtml
页面加载所有依赖项时,您要访问DataTable()函数的视图。。。必须使用该布局页面,否则无法正常工作

最后访问DataTable()函数

  jQuery(document).ready(function(){
           jQuery("#target_table_id").DataTable({
           //...
           //...
       });
    });

从Datatables.net下载所需的依赖项,如js文件和css文件

使用CDN链接

CDN链接包括:

CSS

<link rel="stylesheet" href="cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css" />
<script type="text/javascript" src="cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
//如果是下载的文件

最佳做法是将所有依赖项包含在
App\u Start/BundleConfig.cs
文件中。然后在
Global.asax
文件中注册所有捆绑包

并从
\u Layout.cshtml
中的
Bundle.Config
文件访问所有脚本和CSS,如下所示:

@section scripts {
    <script type="text/javascript" src="cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js"></script>
    //..
}
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")   // in the jquery bundle the the datatables files are included there.
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
有一件事非常重要。。。当从
\u Layout.cshtml
页面加载所有依赖项时,您要访问DataTable()函数的视图。。。必须使用该布局页面,否则无法正常工作

最后访问DataTable()函数

  jQuery(document).ready(function(){
           jQuery("#target_table_id").DataTable({
           //...
           //...
       });
    });