请教一个有关jquery插件Flexigrid的问题

code旅行者 2013-06-24 11:39:57
 $('#flexigridtable').flexigrid({
url: 'GetFlexigridData.ashx',
dataType: 'json',
colModel : [
{ display: 'productId', name: 'productId', width: 60, sortable: true, align: 'center' },
{ display: 'productlistName', name: 'productName', width: 60, sortable: true, align: 'center' },
{ display: 'specification', name: 'specification', width: 140, sortable: true, align: 'left' },
{ display: 'merchantCode', name: 'merchantCode', width: 120, sortable: true, align: 'left' },
{ display: 'sellingStore', name: 'sellingStore', width: 130, sortable: true, align: 'left', hide: false },
{ display: 'priceRange', name: 'priceRange', width: 80, sortable: true, align: 'right' },
{ display: 'repertory', name: 'repertory', width: 80, sortable: true, align: 'right' },
{ display: 'updateTime', name: 'updateTime', width: 80, sortable: true, align: 'right' }
]

});


上面是我的js代码。
 public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";

DataModelDataContext db = new DataModelDataContext();
List<Products> list = db.Products.ToList();
string jsonStr = JsonConvert.SerializeObject(list);
context.Response.Write(jsonStr);
}

上面是我的后台取数据代码,是asp.net的一般处理程序,返回的数据是json字符串,如下:

[{"productId":1,"productName":"ipad","specification":"黑色 8G","merchantCode":"Y001201","sellingStore":"淘宝一电(80)","priceRange":"4000~5000","repertory":80,"updateTime":"2013-06-21T17:06:39.547"},
{"productId":2,"productName":"iphone","specification":"黑色 8G","merchantCode":"Y101201","sellingStore":"拍拍一店(60)","priceRange":"3500~4000","repertory":80,"updateTime":"2013-06-21T17:07:46.913"},
{"productId":3,"productName":"ipad","specification":"黑色 8G","merchantCode":"Y001201","sellingStore":"淘宝一电(80)","priceRange":"4000~5000","repertory":80,"updateTime":"2013-06-21T17:06:39.547"}]

我的问题是为什么前台不显示我的数据内容:


只有一个表头,是不是我的数据格式不对?
...全文
534 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
code旅行者 2013-07-01
  • 打赏
  • 举报
回复
问题已经解决:



网上的答案经我验证都是不靠谱的,以后大家就知道了,Flexigrid在IE下不显示数据的处理方法是:指定一下Ajax请求数据的方式为Get方式
code旅行者 2013-07-01
  • 打赏
  • 举报
回复
问题解决了,原来是后台拼接json数据的时候要对引号进行转义,前端没有问题
sbu.Append("{\"pid\":" + item.productId + ",\"cell\":[\"" + item.productId + "\",\"" + item.productName + "\",\"" + item.specification + "\",\"" + item.merchantCode + "\",\"" + item.sellingStore + "\"");
sbu.Append(",\"" + item.priceRange + "\",\"" + item.repertory + "\",\"" + item.updateTime + "\"]},");



现在有一个新问题,就是我的数据在FF chrome oprea 360等浏览器正常显示数据,但是IE的各个版本都不显示
FF chrome oprea 360等浏览器:


在IE下:


有知道处理方法的朋友吗?谢谢
NANU-NANA 2013-06-24
  • 打赏
  • 举报
回复
http://blog.csdn.net/cuishaofeng/article/details/6311427
code旅行者 2013-06-24
  • 打赏
  • 举报
回复
引用 1 楼 u010087908 的回复:
<table id="flexigridtable"></table>
谢谢,这个我已经写上了,现在怀疑是数据问题,flexigrid需要的数据是不是json字符串
NANU-NANA 2013-06-24
  • 打赏
  • 举报
回复
<table id="flexigridtable"></table>

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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