简体   繁体   English

如何使用ashx文件ASP.NET处理同一页面上的多个jqgrid实例

[英]how to handle multiple jqgrid instances on same page with ashx file ASP.NET

I'm using Webform and Jqgrid to display master-detail information on same page. 我正在使用Webform和Jqgrid在同一页面上显示主从信息。 Here is my Jqgrid definition: 这是我的Jqgrid定义:

  • Master JQGrid: 主JQGrid:

$("#MachineListGrid").jqGrid({ url: 'AdminHandler.ashx', datatype: "json", ... });

  • Detail JQGrid: 详细JQGrid:

$("#MachineDetailListGrid").jqGrid({ url:'AdminHandler.ashx', datatype: "json", ... });

my question is, how does ashx file identify data to return json data back to the correct jqgrid? 我的问题是,ashx文件如何识别数据以将json数据返回到正确的jqgrid? I'd looked at the same between aspx and ashx from this tutorial but the tutorial only gave sample one JQGrid on page. 本教程中,我看过aspx和ashx之间的JQGrid ,但本教程仅在页面上提供了一个JQGrid示例。

on the code, here is the way to capture the request: System.Collections.Specialized.NameValueCollection forms = context.Request.Form; 在代码上,这是捕获请求的方法: System.Collections.Specialized.NameValueCollection forms = context.Request.Form;

The way that will solve the problem is to have two url - one for the master and another for the detail 解决该问题的方法是拥有两个url-一个用于主目录,另一个用于详细信息

$("#MachineListGrid").jqGrid({
    url: 'AdminHandlerMaster.ashx',
    datatype: "json",
    ...
});

$("#MachineDetailListGrid").jqGrid({
    url:'AdminHandlerDatil.ashx',
    datatype: "json",
    ...
});

If you can't do this you may identify it with additional parameter in the post data something like this 如果您无法执行此操作,则可以在发布数据中使用其他参数来标识它,例如:

$("#MachineListGrid").jqGrid({
    url: 'AdminHandler.ashx',
    datatype: "json",
    postData : { gridtype:"master"},
    ...
});

$("#MachineDetailListGrid").jqGrid({
    url:'AdminHandler.ashx',
    datatype: "json",
    postData : { gridtype:"detail"},
    ...
});

In the response you will need to get the gridtype parameter to identify the master and detail data 在响应中,您将需要获取gridtype参数以标识主数据和明细数据

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM