ASP.NET MVC3 Returning Multiple datasets to jqGrid from Controller

In my MVC3 Application I am using a controller actionresult to return two sets of Json data to pass to two separate jqGrids in my view.

The return of the controller's actionresult looks like:

return Json(new
            A= holderA,
            B= holderB

Where A and B are arrays of data that were obtained from LINQ to SQL queries.

I have to jquery jqGrids in my View, and the first one should accept the data from "Part A" of my result, and the second grid should accept the data from "Part B" of my result.

I need to know how to access each individual component of my actionresult (i.e. A and B) in jqGrid, is there a specific option that allows your to reference where the data is coming from?

If it helps here is what one grid looks like...

        url: "/MyController/MyActionresult",
        datatype: 'json',
        postData: {
            Name: function () {
                return $("#Name").val();
            Year: function () {
                return $("#SelectedYear").val()

        mtype: 'POST',
        colNames: ['Name', 'Age', 'Total']
        colModel: [

                { name: 'Name', index: 'Name', align: 'left' },
                { name: 'Age', index: 'Age', align: 'left' },
                { name: 'Total', index: 'Total', width: 150, align: 'left', search: false }],
        pager: jQuery('#GridAPager'),
        rowNum: 250,
        height: 250,
        rowList: [250, 500, 1000, 2000],
        sortname: 'Name',
        sortorder: "asc",
        viewrecords: true,
        hiddengrid: false,
        caption: 'List of People',
        gridComplete: function () {
    $("#GridA").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true });

And the second grid is almost identical with slightly different fields being displayed.

The reason I would prefer to pass both data sets back from one actionresult is because both grids are being populated once a form submit button is clicked.

Any help would be great,



It's important to know the exact format of the data in holderA and holderB. You should define jsonReader which correspond the data structure.

You should understand that if you would uses the option mtype: 'POST' the returned data could not be cached and for filling of "#GridA" and "#GridB" different requests will be done. So you will have no advantage from combining of two responses in one Action.

Moreover if the user click for example on the column header of column 'Name' of "#GridA" one more request will be send to the URL "/MyController/MyActionresult". In the request the value of parameter sord will be "desc" instead of "asc" in the initial request. New requests to the server will be send also if the user change the page size from 250 to 500 or if the user change the page which need be displayed.

I tried to explain that it has sense to have separate actions for all grids which you have on the page. The combining all in one have not so much sense if not all data will be displayed and if you have server side sorting and paging implemented.

Need Your Help

Java, Code Igniter, RoR, DJango web Application Challenge

java ruby-on-rails django programming-languages codeigniter

This is a framework/programming language challenge. I'm looking for programming language that would be best approach for the next project. I want to get some score (out of 10) of their Time to Deve...

Standardize 100 variables in Stata

statistics stata

I was trying to standardize my 100 variables "Apple1, Apple2, Apple3.....". If I did it one by one, it would drive me crazy. I knew foreach and varlist but I don't know how to use it (even finished