北城已荒凉 2018-03-20 16:19 采纳率: 0%
浏览 8

表中没有可用数据

I'm trying to use the datatable in Jquery so I have a Controller with this code:

namespace wb01.Controllers
{
    public class ConsommationsController : Controller
    {
        private database db = new database();

        // GET: Consommations
        public ActionResult Index()
        {
            var consommation = db.Consommation.Include(c => c.Unités_de_prod);

            return View();
        }

        public ActionResult GetList()
        {

            using (database db = new database())
            {
            var listconsom = db.Consommation.ToList<Consommation>();
            return Json(new { data = listconsom }, JsonRequestBehavior.AllowGet);
            }
        }

and in my View I have this code: and in my View I have this code: and in my View I have this code: and in my View I have this code:

@model IEnumerable<wb01.Models.Consommation>

<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/css/jquery.dataTables_themeroller.css">
<br />
<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table @*class="display"*@ id="tableconsommation">
    <thead>
        <tr>
            <th>Date_consommation</th>
            <th>Qtité_consommée</th>
            <th>Id_unité</th>
            <th>Unités_de_prod</th>
        </tr>
    </thead>
 <tfoot>
        <tr>
            <th>Date_consommation</th>
            <th>Qtité_consommée</th>
            <th>Id_unité</th>
            <th>Unités_de_prod</th>
        </tr>
    </tfoot>
</table>


@section scripts {
    <script type="text/javascript" charset="utf8" src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.0/jquery.dataTables.min.js"></script>

    <script>
        $(document).ready(function () {
            $("#tableconsommation").dataTable({
                "ajax": {
                    "url": "/Consommations/GetList",
                    "type": "GET",
                    "datatype": "json" 
                },
                "columns": [
                    { "data": "Date_consommation", "data": "Date_consommation" },
                    { "data": "Qtité_consommée", "data": "Qtité_consommée" },
                    { "data": "Id_unité", "data": "Id_unité" },
                    { "data": "Unités_de_prod", "data": "Unités_de_prod" },
                ],
                "serverSide": "true",
                "order": [0, "asc"],
                "processing": "true",
               });
        });
    </script>
}

but when I run my app, it shows this: enter image description here Or in my database I have more than 5 rows !, someone can help please?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计