Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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
C# 数据表按钮不显示_C#_Jquery_Html_Button_Datatables - Fatal编程技术网

C# 数据表按钮不显示

C# 数据表按钮不显示,c#,jquery,html,button,datatables,C#,Jquery,Html,Button,Datatables,我什么都试过了。我已经阅读了我能找到的每一篇文章、手册和帖子。我尝试下载并运行这些示例,但它甚至无法编译。 我正在使用Visual Studio 2013,使用C编写一个MVC应用程序 以下是BundleConfig.cs中的相关代码: bundles.Add(new ScriptBundle("~/bundles/datatables").Include( "~/Scripts/DataTables/jquery.dataTables.j

我什么都试过了。我已经阅读了我能找到的每一篇文章、手册和帖子。我尝试下载并运行这些示例,但它甚至无法编译。 我正在使用Visual Studio 2013,使用C编写一个MVC应用程序

以下是BundleConfig.cs中的相关代码:

        bundles.Add(new ScriptBundle("~/bundles/datatables").Include(
                    "~/Scripts/DataTables/jquery.dataTables.js",
                    "~/Scripts/DataTables/dataTables.colReorder.js",
                    "~/Scripts/DataTables/dataTables.select.js",
                    "~/Scripts/DataTables/dataTables.fixHeader.js",
                    "~/Scripts/DataTables/dataTables.buttons.js"));

        bundles.Add(new StyleBundle("~/Content/datatables").Include(
                  "~/Content/DataTables/css/jquery.dataTables.css",
                  "~/Content/DataTables/css/colReorder.dataTables.css",
                  "~/Content/DataTables/css/select.dataTables.css",
                  "~/Content/DataTables/css/fixedHeader.dataTables.css",
                  "~/Content/DataTables/css/buttons.dataTables.css"));
以下是.cshtml中的脚本:

<script type="text/javascript">
$(function () {

    $('#budget-data-table').DataTable({
        //dom: 'lft<B>ipr',
        serverSide: true,
        processing: true,
        ajax: '/ConstructionBudget/Get',
        columns: [
           { data: 'ID', visible: false },
           { data: 'BudgetID', visible: false },
           { title: 'Code', data: 'Code' },
           { title: 'Description', data: 'Description' },
           { title: 'Contract Value', data: 'ContractValue' }
        ],
        select: true,
        buttons: ['copy', 'edit', 'delete']
    });

    table.buttons().container().appendTo('#buttonHolder');

});
以下是HTML:

您可以看到,我尝试了dom:属性。当我将其与字符串中的任意位置的“B”一起使用时,表将折叠,并且没有显示任何数据

当我检查HTML时,我在任何地方都找不到任何按钮,除了最后的submit和共享布局的一部分。所有的.css和.js文件都显示在源文件中

我还没有准备好对按钮做任何事情,因为我还不能让它们出现

如有任何见解,将不胜感激。谢谢,

根据

DataTables有许多可用的表控件元素,以及它们在DOM中的位置,即顺序由DOM参数定义

对于按钮,B字符是要使用的字母

所以你的dom应该是


事实上,我最终改变了一些事情。 B不起作用的原因是因为我需要向BundleConfig添加更多的东西:JavaScript的dataTables.bootstrap.js、buttons.bootstrap.js和buttons.flash.js,css的buttons.bootstrap.css。我不确定哪一个有效,但我是从

另一个尝试将buttons表.buttons.container.appendTo添加到'buttonHolder'的原因之一;不起作用是因为我忘了将表变量赋值给DataTable。通过使用Internet Explorer进行测试,我找到了这个。Chrome和Firefox只是忽略了这个声明。我仍然没有工作,但我现在不需要它,因为B正在工作

我怀疑表崩溃可能是浏览器缓存的一个问题,但我无法确定,因为我无法使它在工作时中断。也许明天它会为我打破


无论如何,感谢所有尝试过的人。祝我好运,因为我开始尝试使其可编辑。

Hi Mary,你确定通过方法ConstructionBudget/Get returning response请求的数据吗?是的,在我将“B”添加到dom:属性之前,我会获得可过滤、可搜索、可分页等的数据。然后桌子就塌了谢谢你。。。是的,我已经试过了,但它不起作用。拜托,不管是谁把这个标记为答案,它都不起作用。我仍然有问题。抱歉@marry这帮不了你找到为什么添加一个字符B会导致表格崩溃。。。这与ajax GET中字符数的限制有关。我碰巧刚好在没有B的情况下超过了这个限制。添加一个字符打破了ajax调用。
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-primary list-panel" id="list-panel">
            <div class="panel-heading list-panel-heading">
                <h1 class="panel-title list-panel-title">Construction Budget Line Items</h1>
            </div>
            <div class="panel-body">
                <table id="budget-data-table" class="table table-striped table-bordered" style="width:100%;">

                </table>
                <div class="col-md-12" id="buttonHolder">This is where the buttons might go.</div>
            </div>
        </div>
    </div>
</div>
<div class="form-group">
    <div class="col-md-offset-2 col-md-10">
        <input type="submit" value="Save" class="btn btn-default" />
    </div>
</div>
"dom": 'Bfrtip'