<script type="text/javascript" charset="gb2132">
$(document).ready(function () {
jQuery("#list").jqGrid({
url: 'ashx/BaseBranchManager.ashx?type=GetBaseBranch',
mtype: 'POST',
datatype: "json",
height: 'auto',
width: 500,
colNames: ['编号', '名称'],
colModel: [
{ name: 'BranchID', index: 'BranchID', width: '50' },
{ name: 'BranchDesc', index: 'BranchDesc' }
],
viewrecords: true,
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'CommentID',
jsonReader: {
root: "rows",
page: "pageindex",
total: "pagecount",
records: "total",
repeatitems: false,
id: "0"
},
loadonce: true,
sortname: 'id',
viewrecords: true,
pager: "#pager",
caption: "客户列表",
sortorder: "desc",
hidegrid: false,
onSelectRow: function (ids) {
jQuery("#order").setGridParam({
url: "ashx/Handler.ashx?BranchId=" + ids, page: 1
}).trigger("reloadGrid");
alert(ids);
}
});
jQuery("#list").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false });
jQuery("#order").jqGrid({
url: '',
mtype: 'POST',
datatype: "json",
height: 'auto',
width: 500,
colNames: ['编号'],
colModel: [
{ name: 'BranchID', index: 'BranchID', width: '50' }
],
viewrecords: true,
rowNum: 10,
rowList: [10, 20, 30],
sortname: 'CommentID',
jsonReader: {
root: "rows",
page: "pageindex",
total: "pagecount",
records: "total",
repeatitems: false,
id: "0"
},
loadonce: true,
sortname: 'id',
viewrecords: true,
pager: "#orderppage",
caption: "客户列表",
sortorder: "desc",
hidegrid: false
});
jQuery("#order").jqGrid('navGrid', '#orderppage', { edit: false, add: false, del: false });
});
</script>
上面是我一个主从表的代码,也就是点击一个列后,另一个表根据ID绑定数据!但是出现这样的情况,就是说,第一次点击的时候,就会进入BaseBranchManager.ashx文件中,但是第二次再点击就不可以!BaseBranchManager.ashx代码如下:
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "application/json";
string resultJson = "";
if (context.Request["type"] == "GetBaseBranch")
{
resultJson = GetBaseBranch();
}
if (context.Request["type"] == "GetOrderCar")
{
resultJson = SelectOrderdtByBanchId(context.Request["BranchId"].ToString());
}
context.Response.Write(resultJson);
}
private static string GetBaseBranch()
{
WcfService.ProductsServiceClient pr = new WcfService.ProductsServiceClient();
DataTable dt = pr.GetBaseBranch();
// 每页显示记录数
int pageSize = 10;
// 记录总数
int rowCount = dt.Rows.Count;
// 总页数
int pageCount = rowCount % pageSize == 0 ? rowCount / pageSize : rowCount / pageSize + 1;
var resultObj = new DataResult
{
// 总页数
PageCount = pageCount,
// 当前页
PageIndex = 1,
// 总记录数
Total = rowCount,
// 数据
Data = dt
};
string resultJson = JsonHelper.Serialize(resultObj);
return resultJson;
}
试过用其他ASP页面来实现,但是如果我用 Response.End()的话,就第二次不进来执行方法,不用 Response.End()的话,又不显示数据!请问这是什么回事呢!
添加回答
举报
0/150
提交
取消