TypechoJoeTheme

香草物语

统计
登录
用户名
密码
/
注册
用户名
邮箱
输入密码
确认密码

asp.net core中bootstrap-table无法获取返回的Json数据

Laughing博主
2017-11-29
/
0 评论
/
1,211 阅读
/
159 个字
/
百度已收录
11/29
本文最后更新于2020年09月26日,已超过1310天没有更新。如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

之前在ASP.NET Core下面,通过bootstrap-table也展示过数据,当时也是在controller中直接返回了Json对象,当时没有任何问题,但是今天测试的时候,发现返回的数据不能展示了,所有的数据都变成了 -,其实就是数据有问题,但是查看返回的Json数据的时候,Json数据格式也没有任何问题。

处理Json返回的数据

更多调试发现,Json对象还有一个JsonSerializerSettings参数的重载函数,然后直接实例化了一个JsonSerializerSettings对象,然后返回Json就可以了,具体如下

var rows = productHelper.GetProductPager(limit, offset);  
          int total = rows.Count();  
          JsonSerializerSettings settings = new JsonSerializerSettings();  
          //settings.MaxDepth = 50;  
          //settings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //设置不处理循环引用  
          //转成Json格式  
          return Json(new { total = total, rows = rows }, settings);  
          //return Json(new { total = total, rows = rows });
JSONasp.netasp.net core
朗读
赞(22)
赞赏
感谢您的支持,我会继续努力哒!
版权属于:

香草物语

本文链接:

https://www.xiangcaowuyu.net/java/asp-net-core-bootstrap-table-json-data.html(转载时请注明本文出处及文章链接)

评论 (0)
  1. 孤狼2号 闲逛
    Windows 7 · Google Chrome

    能用吗?谢谢分享

    2018-11-16 回复
  2. tet 闲逛
    MacOS · Google Chrome

    谢谢

    2018-07-07 回复