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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:59:13+00:00 2026-05-27T10:59:13+00:00

I have a jqGrid on a view page and it is loaded based on

  • 0

I have a jqGrid on a view page and it is loaded based on gathering data from a few select lists.

The first time through all is fine. If I change one of the select lists the .change function is triggered but the .jqGrid doesnt fire so the Controller method isnt hit.

My jqGrid code

$("#Builds").change(function () {
    var programID = $("#ProgramID").val();
    var buildID =  $('#Builds').val();
     $("#UpdateBuild").show();

    // Set up the jquery grid
    $("#jqTable").jqGrid({
        // Ajax related configurations
        url: '@Url.Action("_CustomBinding")',
        datatype: "json",
        mtype: "POST",
        postData: {
            programID: programID,
            buildID: buildID
            },

        // Specify the column names
        colNames: ["Assembly ID", "Assembly Name", "Cost", "Order", "Budget Report", "Partner Request", "Display"],

        // Configure the columns
        colModel: [
        { name: "AssemblyID", index: "AssemblyID", width: 40, align: "left", editable: false },
        { name: "AssemblyName", index: "AssemblyName", width: 100, align: "left", editable: false },
        { name: "AssemblyCost", index: "AssemblyCost", width: 40, align: "left", formatter: "currency", editable: true },
        { name: "AssemblyOrder", index: "AssemblyOrder", width: 30, align: "left", editable: true },
        { name: "AddToBudgetReport", index: "AddToBudgetReport", width: 40, align: "left", formatter: "checkbox", editable:true, edittype:'checkbox'},
        { name: "AddToPartnerRequest", index: "AddToPartnerRequest", width: 45, align: "left", formatter: "checkbox", editable:true, edittype:'checkbox'},
        { name: "Show", index: "Show", width: 20, align: "left", formatter: "checkbox", editable:true, edittype:'checkbox'}],

        // Grid total width and height and formatting
        width: 650,
        height: 200,
        altrows: true,

        // Paging
        toppager: true,
        pager: $("#jqTablePager"),
        rowNum: 10,
        rowList: [10, 20, 30],
        viewrecords: true, // Specify if "total number of records" is displayed
        emptyrecords: 'No records to display',

        // Default sorting
        sortname: "AssemblyID",
        sortorder: "asc",

        // Grid caption
        caption: "Build Template"

    }).navGrid("#jqTablePager",
        { refresh: true, add: true, edit: true, del: true },
            {}, // settings for edit
            {}, // settings for add
            {}, // settings for delete
            {sopt: ["cn"]} // Search options. Some options can be set on column level
     );
});

My controller Code:

[HttpPost]
public JsonResult _CustomBinding(string programID, string buildID, int page, int rows)
{
    /* Variable Declarations */
    BuildsRepository br = new BuildsRepository();
    IEnumerable<ProgramsAssemblyBuilds> pab = br.GetProgramAssembliesBuilds(Convert.ToInt32(programID), Convert.ToInt32(buildID));

    // Calculate the total number of pages
    var totalRecords = pab.Count();
    var totalPages = (int)Math.Ceiling((double)totalRecords / (double)rows);

    var data = (from s in pab
                select new
                {
                    AssemblyID = s.AssemblyID,
                    cell = new object[] { s.AssemblyID, s.AssemblyName, s.AssemblyCost, s.AssemblyOrder, s.AddToBudgetReport, s.AddToPartnerRequest, s.Show}
                }).ToArray();

    var jsonData = new
    {
        total = totalPages,
        page = page,
        records = totalRecords,
        rows = data.Skip((page - 1) * rows).Take(rows)
    };
    return Json(jsonData, JsonRequestBehavior.AllowGet);
}

Anyone have any ideas on this one?

Thanks

  • 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-27T10:59:13+00:00Added an answer on May 27, 2026 at 10:59 am

    You should create the grid only once. So you should place the code

     $("#jqTable").jqGrid({ ... });
    

    outside of the change event handler.

    To reload the grid you should use

    $("#Builds").change(function () {
        $("#jqTable").trigger("reloadGrid", [{page: 1}]);
        $("#UpdateBuild").show();
    });
    

    At the end to have actual values from "#ProgramID" and '#Builds' you should use functions (methods) as the programID and buildID properties of postData:

    // Set up the jquery grid
    $("#jqTable").jqGrid({
        // Ajax related configurations
        url: '@Url.Action("_CustomBinding")',
        datatype: "json",
        mtype: "POST",
        postData: {
            programID: function() { return $("#ProgramID").val(); },
            buildID: function() { return $('#Builds').val(); }
        },
        ...
    });
    

    See more information here.

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

Sidebar

Related Questions

I have jqGrid 3.5 (full) mostly working. I have it retrieving data with the
I have a jqGrid on a page and users can click a button to
I have a jqGrid with which users will select records. A large number of
I have a couple of columns in jqGrid with edittype=select. How can I read
I have a case where I need to update a jqgrid based on some
I have a asp.net webforms page in which I'm using the jqGrid component. The
I have a jqGrid on an ASP.Net MVC view. I want to use to
I have a jqgrid showing 117 total records in 50 rows per page (rowNum
I have a PHP script that extract valid GeoJSON data from a database. Now
I have jqGrid with enabled EDIT, DELETE, ADD and VIEW , Now my problem

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.