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 923803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:14:57+00:00 2026-05-15T19:14:57+00:00

I have 2 Grids on my HTML page. When I click a row in

  • 0

I have 2 Grids on my HTML page.
When I click a row in one grid, it needs to load data into the other based on the selected row.

Therefore I need to send the rowId as an extra parameter for the second grid.. Can’t figure out how..

(I’d rather not like to use the subgrid functionality)

  • 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-05-15T19:14:57+00:00Added an answer on May 15, 2026 at 7:14 pm

    You can find an example of this scenario on http://trirand.com/blog/jqgrid/jqgrid.html if you choose “Advanced” and then “Master Detail”. I include below a small variation of the code.

    Let us we have two grids on the HTML page: one “master” grid and another “details” grid, which needs to load data based on the row selected into the master grid. Let us both grids must fill the data from the server which send back the data in the JSON format. We suppose , that we use single row selection (no multiselect: true is defined) in the master grid.

    Here is the code template

    var detailsTitle = 'Details';
    var grid = jQuery('#master').jqGrid({ // ... some parameters
        url: masaterUrl,
        datatype: 'json',
        colModel: [ // ... some column definitions
            { name: 'Name', width: 120 }
        ],
        onSelectRow: function(id) {
            var selName = grid.getCell(id, 'Name');
            gridDetails.setCaption(detailsTitle + ' for "' + selName + '"');
            gridDetails.setGridParam({
                //url: urlGetDetail + '/' + encodeURIComponent(id),
                //url: urlGetDetail + '?' + $.param( { userId: id });
                postData: { userId: id },
                page: 1,
                datatype: 'json' }).trigger('reloadGrid');
        }
    }).navGrid('#pager', {}, {}, {}, {
        afterSubmit: function(response, postdata) {
            gridDetails.setCaption(detailsTitle);
            gridDetails.setGridParam({ datatype: 'local',
                                       page: 1 }).trigger('reloadGrid');
            return [true, ''];
        }
    });
    
    var gridDetails = jQuery('#detail').jqGrid({ // ...
        caption: detailsTitle,
        url: urlDetail,
        //postData: { userId: function() { return grid.getGridParam('selrow'); } },
        datatype: 'local'
    });
    

    Now some comments to the code. At the beginning no rows will be selected in the master grid. So we set datatype: 'local' as a parameter of details grid to deny and data loading.

    If a row in the master grid will be selected we set the title (the caption) of the details grid, change datatype of details grid to 'json' and set page: 1. Resetting of the page parameter is important because it will be send to the server as additional parameter. If at the last selection the user choosed another page before and for the new selection there are not so many datails rows as before the details grid could be empty. To fix the problem we should set always page to 1.

    Now the main work: sending the id of the master grid as a parameter of the server request for the details grid. We have some options here:

    • we can append the url of details grid with a string like '?userId='+id. To do this more carefully we should take in consideration that id can has some special characters. So to be sure we should use '?userId='+encodeURIComponent(id) instead. The function jQuery.param do the same in more readable form. So we can use '?'+jQuery.param({userId:id}) instead. I recommend to use the way if the url of the details grid should be in the REST format (like “blabla/id”). In this case the setting of url of the details grid to urlDetail+'/'+encodeURIComponent(id) is probably the best way.
    • we can set parameter postData:{userId:id}. It follows to the same as '?'+jQuery.param({userId:id}) if we use HTTP GET for the requests to the server. The advantage of the way is that we use also HTTP POST. Then the parameters will be posted in the body instead of appended to the URL. So the usage of postData has a small advantage.
    • we can remove the code from onSelectRow event of the master grid and include in the the detail grid an additional parameter postData as a function (see commented line). The way will work very good with small exceptions. For example, it will be difficult for us to clear the details grid if the selected row in the master grid will be deleted. In some other situations we have also less flexibility. So I wanted only mention this possibility, but I included it only as a comment (see How to filter the jqGrid data NOT using the built in search/filter box if you have interest to this way).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many applications have grids that display data from a database table one page at
I have a tabbed series of grids on a data preview page. I now
Suppose I have a grid with some row definitions, and a child control in
I have an ExtJS grid on a web page and I'd like to save
I have a Data Grid View inside a control that is displayed in a
I have a data grid that has a checkbox item renderer in a cloumn
I have a grid laid out like so; +---------+---------+ | Image | Details |
Here's the scenario I have a Grid with some TextBlock controls, each in a
I have a Property Grid in C#, loading up a 'PropertyAdapter' object (a basic
I have two different grid controls on the same form. They share the same

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.