求指教,一个mvc4 和easyui的问题

2017-01-10 09:00 出处:360java.com 作者:360java  阅读()
我在布局页面里引入了样式和js@Styles.Render(quot;~/EasyUI/themes/default/easyui.cssquot;) @Styles.Render(quot;~/EasyUI/themes/...

我在布局页面里引入了样式和js

@Styles.Render("~/EasyUI/themes/default/easyui.css")
@Styles.Render("~/EasyUI/themes/icon.css")
@Scripts.Render("~/EasyUI/jquery-1.7.2.min.js")
@Scripts.Render("~/EasyUI/jquery.easyui.min.js")
@Scripts.Render("~/EasyUI/locale/easyui-lang-zh_CN.js")

控制器里面的方法是:

//
// GET: /Admins/
public JsonResult Index()
{
     List<Admins> list = db.adminList.ToList();
     var date = new { total = list.Count, rows = (list) };
     return Json(date, JsonRequestBehavior.AllowGet);
}

返回给页面的json数据是:

{"total":5,"rows":[{"ID":2,"Account":"aaa","PWD":"111","Name":null,"Tel":null,"Email":null,"Introduce":null,"Rank":null,"Rights":null,"Created":"\/Date(1373817600000)\/","Enabled":0,"ChannelStr":null,"ColumnStr":null},{"ID":3,"Account":"bbb","PWD":"222","Name":null,"Tel":null,"Email":null,"Introduce":null,"Rank":null,"Rights":null,"Created":"\/Date(1373817600000)\/","Enabled":0,"ChannelStr":null,"ColumnStr":null},{"ID":4,"Account":"ccc","PWD":"333","Name":null,"Tel":null,"Email":null,"Introduce":null,"Rank":null,"Rights":null,"Created":"\/Date(1373817600000)\/","Enabled":0,"ChannelStr":null,"ColumnStr":null},{"ID":5,"Account":"ddd","PWD":"444","Name":null,"Tel":null,"Email":null,"Introduce":null,"Rank":null,"Rights":null,"Created":"\/Date(1373817600000)\/","Enabled":0,"ChannelStr":null,"ColumnStr":null},{"ID":6,"Account":"eee","PWD":"555","Name":null,"Tel":null,"Email":null,"Introduce":null,"Rank":null,"Rights":null,"Created":"\/Date(1373817600000)\/","Enabled":0,"ChannelStr":null,"ColumnStr":null}]}

在视图中的用easyui绑定这些数据,居然绑定不出来。

<table id="list"></table>
<script type="text/javascript">
$(function () {
  $('#list').datagrid({
    url: 'Admins/Index',//控制器/方法
    columns: [[
      { field: 'Account', title: '帐号', width: 100 },
      { field: 'PWD', title: '密码', width: 100 },
      { field: 'Created', title: '创建时间', width: 100, align: 'right' }
    ]]
  });
});
</script>


绑定失败了,看到的页面是,上面那一堆json数据,为什么会这样呢?
最佳答案

Json数据源先使用最简单的字段,不要弄得那么多字段,把日期先去掉试试,然后一个一个试。看起来没有什么问题,具体你需要慢慢去调试。

控制器需要什么 [] 修饰么?

我觉得不是代码的问题了,是不是环境的问题啊?

分享到:

相关文章

发表评论(共条评论)愿您的每句评论,都能给大家的生活添色彩,带来共鸣,带来思索,带来快乐。

Copyright (C) java学习 360java 360java.com, All Rights Reserved.

苏ICP备16022210号