Response.Write()输出Json,为什么Jqgrid无法接收,直接在页面上输出了
后台:protectedvoidPage_Load(objectsender,EventArgse){CreateJson();}publicvoidCreateJson...
后台:
protected void Page_Load(object sender, EventArgs e)
{
CreateJson();
}
public void CreateJson()
{
HY_MemberMan mber = new HY_MemberMan();
DataSqlMan dss = new DataSqlMan();
String sqlstr = "select top 2 HotelID,isBlankOut,CardTypeName,CardName,SumMoney from HY_Member";
DataTable table = dss.GetTableList(sqlstr);
String data = JsonHandle.GetJson("HotelID", table);
Response.Write(data);
Response.End();
}
前台:
<script type="text/javascript">
$(document).ready(function () {
$("#jqGridList").jqGrid({
url: "JQGrid_Json_3_8.aspx",
datatype: "json",
width : "700",
colNames: ['店号', '是否会员', '卡类型', '卡名称', '累计金额'],
colModel: [
{ name: 'HotelID', index: 'HotelID', width: 100 },
{ name: 'isBlankOut', index: 'isBlankOut', width: 100 },
{ name: 'CardTypeName', index: 'CardTypeName', width: 100 },
{ name: 'CardName', index: 'CardName', width: 100, align: "right" },
{ name: 'SumMoney', index: 'SumMoney', width: 100, sortable: false }
],
rowNum:10,
rowList:[10, 20, 30],
pager:'#pager2',
sortname:'id',
viewrecords: true, //是否显示行数
sortorder: "desc", //排序方式
multiselect: true, //是否支持多选
caption: "JSON Example"
}).navGrid('#pager2', { edit: true, add: true, del: true });
}); 展开
protected void Page_Load(object sender, EventArgs e)
{
CreateJson();
}
public void CreateJson()
{
HY_MemberMan mber = new HY_MemberMan();
DataSqlMan dss = new DataSqlMan();
String sqlstr = "select top 2 HotelID,isBlankOut,CardTypeName,CardName,SumMoney from HY_Member";
DataTable table = dss.GetTableList(sqlstr);
String data = JsonHandle.GetJson("HotelID", table);
Response.Write(data);
Response.End();
}
前台:
<script type="text/javascript">
$(document).ready(function () {
$("#jqGridList").jqGrid({
url: "JQGrid_Json_3_8.aspx",
datatype: "json",
width : "700",
colNames: ['店号', '是否会员', '卡类型', '卡名称', '累计金额'],
colModel: [
{ name: 'HotelID', index: 'HotelID', width: 100 },
{ name: 'isBlankOut', index: 'isBlankOut', width: 100 },
{ name: 'CardTypeName', index: 'CardTypeName', width: 100 },
{ name: 'CardName', index: 'CardName', width: 100, align: "right" },
{ name: 'SumMoney', index: 'SumMoney', width: 100, sortable: false }
],
rowNum:10,
rowList:[10, 20, 30],
pager:'#pager2',
sortname:'id',
viewrecords: true, //是否显示行数
sortorder: "desc", //排序方式
multiselect: true, //是否支持多选
caption: "JSON Example"
}).navGrid('#pager2', { edit: true, add: true, del: true });
}); 展开
2个回答
展开全部
能发上来返回的json格式的数据么?从你的代码看,如果能返回json格式的数据,也不符合jqgrid的要求,格式要
{"page":1,"total":2,"records":2,"rows":
[{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","白金卡"]}]
}
这样的才符合
参照我在这的回答
http://zhidao.baidu.com/question/350265704.html
{"page":1,"total":2,"records":2,"rows":
[{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","金钻卡"]},{"id":"SNMZ","cell":["SNMZ","n","白金卡"]}]
}
这样的才符合
参照我在这的回答
http://zhidao.baidu.com/question/350265704.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询