简体   繁体   中英

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. Here is my Jqgrid definition:

  • Master JQGrid:

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

  • Detail 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? I'd looked at the same between aspx and ashx from this tutorial but the tutorial only gave sample one JQGrid on page.

on the code, here is the way to capture the request: 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

$("#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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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