从ASP.NET Web API加载数据表时出现的问题 [英] Problems in loading datatables from ASP.NET web API
本文介绍了从ASP.NET Web API加载数据表时出现的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用datatable js库在Web API中进行搜索过滤和排序。但是没有任何东西出现在负载上。
我尝试过:
在Layout.CSHTML
I am trying to do searching filtering and sorting in web API using datatable js library. But nothing is showing up on load.
What I have tried:
At Layout.CSHTML
@Scripts.Render("~/bundles/lib")
@RenderSection("scripts", required: false)
</body>
in Bundles.Config
in Bundles.Config
bundles.Add(new ScriptBundle("~/bundles/lib").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/bootstrap.js",
"~/scripts/bootbox.js",
"~/Scripts/respond.js",
"~/scripts/datatables/jquery.datatables.js",
"~/scripts/datatables/datatables.bootstrap.js"
));
主要指数中的
in main Index.html
<script>
$(document).ready(function () {
$("#customers").DataTable();
$("#customers").on("click", ".js-delete", function () {
var button = $(this);
bootbox.confirm("Are you Sure you want to delete this customer?",function(result){
if(result){
$.ajax({
url: "/api/customers/" + button.attr("data-customer-id"),
method: "DELETE",
success: function () {
button.parents("tr").remove();
}
});
}
});
});
});
</script>
推荐答案
(document).ready(function(){
(document).ready(function () {
( #customers)。DataTable();
("#customers").DataTable();
(#customers)。on(click,。js-delete,function(){
var button =
("#customers").on("click", ".js-delete", function () { var button =
这篇关于从ASP.NET Web API加载数据表时出现的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文