ASP.NET MVC EasyUI DataGrid显示数据问题-CSDN论坛

浅析丶 2017-11-28 02:28:42
前台:
$(function () {
$('#dg').datagrid({
url: 'CustomerArea/CustomerPage/ActivitysPage',
method: 'GET', //默认是post,不允许对静态文件访问
dataType: 'JSON',
fitColumns: true,
columns: [[
{
field: 'ActDate', title: '时间', width: 100,
formatter: function (value, row, index) {
try {
var date = new Date(parseInt(/\d+/.exec(value)[0]));
var year = parseInt(date.getFullYear());
if (year > 2500 || year < 1900)
{ return ""; }
return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
} catch (e) {
return "";
}
}
},
{ field: 'ActAdd', title: '地点', width: 100 },
{ field: 'ActTitle', title: '概要', width: 100 },
{ field: 'ActDesc', title: '详细信息', width: 100 },
{ field: 'ActID', title: '操作', width: 100,
formatter: function (value, row, index) {
return '<a href="ActivitysEdit.htm?"><img title="编辑" src="/images/33.gif"style="border:0px" /></a> <img title="删除" src="/images/11.gif" />'
}
}
]],
singleSelect: true//不允许选择多行
});
})

后台:
public ActionResult ActivitysPage()
{
ActivitysBLL ABLL = new ActivitysBLL();
List<Activitys> list = ABLL.GetAllInfo();
return Json(list, JsonRequestBehavior.AllowGet);
}

实体类:
public class Activitys: ModelBase
{
public System.Int32? ActID{get;set;}
public System.String CusID{get;set;}
public System.String CusName{get;set;}
public System.DateTime? ActDate{get;set;}
public System.String ActAdd{get;set;}
public System.String ActTitle{get;set;}
public System.String ActDesc{get;set;}
}
不知道为什么显示的页面是这样的
...全文
250 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
浅析丶 2017-11-28
  • 打赏
  • 举报
回复
可以结贴了不,不久前注册的CSDN账号好多东西都不知道
浅析丶 2017-11-28
  • 打赏
  • 举报
回复
引用 4 楼 dengchenlu 的回复:
你这写法有问题吧。 应该还有一个显示页面的方法,例如Index。 在Index页面加载表格,表格中才通过AJAX请求CustomerArea/CustomerPage/ActivitysPage,获得数据绑定到表格。 你现在是直接访问的CustomerArea/CustomerPage/ActivitysPage,页面给你显示JSON没错啊
确实是你说的这样,谢谢提出我这个错误
全栈极简 2017-11-28
  • 打赏
  • 举报
回复
你直接访问后台的action干嘛,你应该访问装有js的view呀。
dengchenlu 2017-11-28
  • 打赏
  • 举报
回复
你这写法有问题吧。 应该还有一个显示页面的方法,例如Index。 在Index页面加载表格,表格中才通过AJAX请求CustomerArea/CustomerPage/ActivitysPage,获得数据绑定到表格。 你现在是直接访问的CustomerArea/CustomerPage/ActivitysPage,页面给你显示JSON没错啊
浅析丶 2017-11-28
  • 打赏
  • 举报
回复
引用 1 楼 hanjun0612 的回复:
改成 JsonResult呢? public JsonResult ActivitysPage() { ActivitysBLL ABLL = new ActivitysBLL(); List<Activitys> list = ABLL.GetAllInfo(); return Json(list, JsonRequestBehavior.AllowGet); }
试了一下没有用
浅析丶 2017-11-28
  • 打赏
  • 举报
回复
试了一下没有用
正怒月神 版主 2017-11-28
  • 打赏
  • 举报
回复
改成 JsonResult呢? public JsonResult ActivitysPage() { ActivitysBLL ABLL = new ActivitysBLL(); List<Activitys> list = ABLL.GetAllInfo(); return Json(list, JsonRequestBehavior.AllowGet); }

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧