Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:07:37+00:00 2026-06-12T15:07:37+00:00

I’m developing an MVC3/razor application, and I am trying to use the subGridRowExpanded to

  • 0

I’m developing an MVC3/razor application, and I am trying to use the subGridRowExpanded to nest a jqGrid inside another (so I can use the formatter amongst other things), how do i pass the id value Of the parent Grid to the Child grid?

The below code runs the main grid, and populates it with Data from the “Search/Customers” URL, but I do not know how to select the record I’ve Selected in the ‘Search/BankLinks’ URL controller

Can anyone tell me how to do this?

Thanks in advance
Andrew.

My Index.cshtml

@{
    ViewBag.Title = "Index";
}

<h2>@ViewBag.Message</h2>
<div id="content">
    <div id="content-left">
        @Html.Partial("SearchPanel")
    </div>
    <div id="content-main">
        <table id="jpgCustomers" cellpadding="0" cellspacing="0"></table>
        <div id="jpgpCustomers" style="text-align:center;"></div>
    </div>
</div>
@section JavaScript
{
<script type="text/javascript">
    $(document).ready(function ()
    {
        $('#jpgCustomers').jqGrid({
            //url from wich data should be requested
            url: '@Url.Action("Customers")',
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Name', 'FullName', 'SFTP Enabled', 'IsTranbase'],
            colModel: [
                { name: 'LogonName', index: 'LogonName', align: 'left' },
                { name: 'FullName', index: 'FullName', align: 'left' },
                { name: 'Enabled', index: 'Enabled', align: 'left' },
                { name: 'IsTran', index: 'IsTranbase', align: 'left' }
            ],
            pager: $('#jpgpCustomers'),
            rowNum: 10,
            sortname: 'FullName',
            sortorder: 'asc',
            viewrecords: true,
            height: '100%',
            subGrid: true,
            subGridRowExpanded: function(subgrid_id, row_id) {
                var subgrid_table_id, pager_id;
                subgrid_table_id = subgrid_id+"_t";
                pager_id = "p_"+subgrid_table_id;
                $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"'class='scroll'></table><div id='"+pager_id+"'class='scroll'></div>");
                $("#"+subgrid_table_id).jqGrid({
                    url: '@Url.Action("BankLinks")',
                    datatype: 'json',
                    mtype: 'POST',
                    colNames: ['Bank', 'Folder', 'Enabled'],
                    colModel:[
                        {name:"Bank",index:"Bank",width:80,key:true},
                        {name:"Folder",index:"Folder",width:130},
                        {name:"Enabled",index:"Enabled",width:70,align:"left"}
                    ],
                    rowNum:20,
                    pager: pager_id,
                    sortname: 'Bank',
                    sortorder: "asc",
                    viewrecords: true,
                    height: '100%'
                });
                $("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false})
            },
        });
    });
</script>
}

My Controller Actions:

Customers

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Customers(JqGridRequest request)
{
    ISession session = NHibernateHelper.GetCurrentSession();
    IEnumerable<Customer> customers = session.QueryOver<Customer>().List().Skip<Customer>(0).Take<Customer>(request.RecordsCount);

    int totalRecords = customers.Count();

    //Prepare JqGridData instance
    JqGridResponse response = new JqGridResponse()
    {
        //Total pages count
        TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
        //Page number
        PageIndex = request.PageIndex,
        //Total records count
        TotalRecordsCount = totalRecords
    };
    //Table with rows data
    foreach (Customer customer in customers)
    {
        response.Records.Add(new JqGridRecord(Convert.ToString(customer.Id), new List<object>()
        {
            customer.FtpDetails.LogonName,
            customer.FtpDetails.FullName,
            customer.FtpDetails.Enabled,
            customer.IsTran
        }));
    }

    //Return data as json
    return new JqGridJsonResult() { Data = response };
}

BankLinks

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult BankLinks(JqGridRequest request)
{
    ISession session = NHibernateHelper.GetCurrentSession();

    //IN THIS LINE I HAVE HARDCODED value 14 - I need this value to be passed from the 
    //Parent Grid!
    Customer customer = session.Get<Customer>(14);

    int totalRecords = customer.Banks.Count();

    //Prepare JqGridData instance
    JqGridResponse response = new JqGridResponse()
    {
        //Total pages count
        TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
        //Page number
        PageIndex = request.PageIndex,
        //Total records count
        TotalRecordsCount = totalRecords
    };

    foreach (Bank bank in customer.Banks.ToList<Bank>())
    {
        CustomerBank bankLink = session.QueryOver<CustomerBank>().Where(x => x.BankId == bank.Id).Where(y => y.CustomerId == customer.Id).List<CustomerBank>().FirstOrDefault();

        response.Records.Add(new JqGridRecord(null, new List<object>()
        {
            bank.BankCode,
            bank.Folder,
            bankLink.Enabled 
        }));
    }
     return new JqGridJsonResult() { Data = response };
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:07:38+00:00Added an answer on June 12, 2026 at 3:07 pm

    First you should modify your subGridRowExpanded callback like this:

    subGridRowExpanded: function(subgrid_id, row_id) {
        var subgrid_table_id, pager_id;
        subgrid_table_id = subgrid_id + '_t';
        pager_id = "p_"+subgrid_table_id;
        $('#' + subgrid_id).html('<table id="' + subgrid_table_id + '" class="scroll"></table><div id="' + pager_id + '" class="scroll"></div>');
        $('#' + subgrid_table_id).jqGrid({
            url: encodeURI('@Url.Action("BankLinks")' + '?id=' + row_id),
            datatype: 'json',
            mtype: 'POST',
            colNames: ['Bank', 'Folder', 'Enabled'],
            colModel: [
                {name: 'Bank', index: 'Bank', width:80, key:true },
                {name: 'Folder', index:'Folder', width:130 },
                {name: 'Enabled', index: 'Enabled', width:70, align: 'left' }
            ],
            rowNum: 20,
            pager: pager_id,
            sortname: 'Bank',
            sortorder: 'asc',
            viewrecords: true,
            height: '100%'
        });
        $('#' + subgrid_table_id).jqGrid('navGrid', '#' + pager_id, {edit: false, add: false, del: false })
    }
    

    Notice the usage of encodeURI in order to make sure that the produced URL is valid.

    Now you can modify your action method like this:

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult BankLinks(int id, JqGridRequest request)
    {
        //You can sue id parameter to get the data for selected client.
        ...
    }
    

    This should do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.