我在布局页面里引入了样式和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数据源先使用最简单的字段,不要弄得那么多字段,把日期先去掉试试,然后一个一个试。看起来没有什么问题,具体你需要慢慢去调试。
控制器需要什么 [] 修饰么?
我觉得不是代码的问题了,是不是环境的问题啊?
貌似没啥问题额,换个jquery版本呢?
columns获取列有问题
什么问题?愿闻其详