JS代码
<script type="text/javascript">
$(function () {
$("#datagrid").datagrid({
url: '@Url.Content("~/PowerManage/PowerDataView")',
fitColumns: true,
fit: true,
border: false,
loadMsg: '努力加载中',
toolbar: '#toolbar',
pagination: false,
striped: true,
rownumbers: true,
singleSelect: true,
columns: [[
{
title: "权限名称",
field: "name",
width: 150
},
{
title: "权限标识",
field: "identify",
width: 200
},
{
title: "权限描述",
field: "description",
width: 100,
},
{
title: "操作",
width: 80,
field: 'action',
formatter: function (value, row, index) {
var str = '';
str += '<a href="javascript:void(0);" onclick="edit(\'' + row.id + '\');" > 编辑<a/> ';
str += '<a href="javascript:void(0);" onclick="del(\'' + row.id + '\');">删除<a/>';
return str;
}
}
]]
});
});
</script>
后台Controller
public ActionResult PowerDataView()
{
List<Model.UserPowers.Powers> list = new List<Model.UserPowers.Powers>(4);
Powers power1 = new Powers("超级管理员", "所有权限", "管理所有用户");
Powers power2 = new Powers("领导", "管理权限", "管理一般用户");
Powers power3 = new Powers("一般用户", "查看权限", "查看数据");
list.Add(power1);
list.Add(power2);
list.Add(power3);
//var returnData = Json(list, JsonRequestBehavior.AllowGet);
return View();
}
Power类
public class Powers
{
public string name { get; set; }
public string identify { get; set; }
public string description { get; set; }
public Powers(string name1, string identify1, string description1)
{
name = name1;
identify = identify1;
description = description1;
}
}
求大神指导
把ActionResult改为JsonAction
return Json(list, JsonRequestBehavior.AllowGet);
谢谢...问题已经解决了!