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

  • Home
  • SEARCH
  • 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 8448469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:26:11+00:00 2026-06-10T10:26:11+00:00

I created a reusable function for creating jqGrid. function createJqGrid(){ $(# + gTableId).jqGrid({ datastr:

  • 0

I created a reusable function for creating jqGrid.

function createJqGrid(){
    $("#" + gTableId).jqGrid({
            datastr: jsonData,
            datatype: 'jsonstring',
            jsonReader: { repeatitems: false, root: function(obj) { return obj; }},
            headertitles: true,
            sortable: true,
            rownumbers: isRowNum,
            colNames: colHeadNames,
            colModel: colModel,
            rowNum: jsonData.length,
            width: viewableWidth,
            height: viewableHeight,     
            shrinkToFit: isShrink,
            scrollOffset: 0,
            onSelectRow: func,
            loadComplete: function(data) {
                alert(gTableId);                
            }
        });
}

This function and all the setting of parameters is encapsulated inside MyObject. My four jsp’s have their own distinct instance of MyObject. But when I trigger a reloadGrid of jqGrid, the id of the last table that used this function is being alerted.

Given:
table1 is inside table1.jsp
table2 is inside table2.jsp
table3 is inside table3.jsp
table4 is inside table4.jsp

$("#table1").trigger("reloadGrid"); alerts “table4”
$("#table2").trigger("reloadGrid"); alerts “table4”
$("#table3").trigger("reloadGrid"); alerts “table4”
$("#table4").trigger("reloadGrid"); alerts “table4”

Seems like the loadComplete of the last created table is being triggered. Why is it so?

  • 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-10T10:26:12+00:00Added an answer on June 10, 2026 at 10:26 am

    I do believe that the triggered loadComplete is the correct one and the issue is more with the logic of your JavaScript. The variables declaration section is missing in your sample but it looks like gTableId is a global variable. In that case every call to it will always get its last value (and your alert is always taking the current value of gTableId, it’s not freezed in any way). Please try modifying your loadComplete like this to verify:

    loadComplete: function(data) {
        alert($(this).attr('id');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is the scenario : 1) Created on Web Application project for reusable user
I am trying to create a reusable function that can open a single instance
I am trying to create a reusable function that checks if a variable is
I would like a reusable function that simply does a BlurEffect on any particular
I have been tasked with creating a reusable process for our Finance Dept to
I'm looking to create a reusable function that will generate a random key with
I'm creating a reusable flex tree component. And i would like to stick in
I'm trying to create a reusable component to display some photo collection. The basic
I am trying to create some reusable components in Silverlight2 . The difficulty comes
Background I am attempting to create a reusable chart object with D3.js . I

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.