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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:45:15+00:00 2026-06-08T16:45:15+00:00

Looking at Oleg solution for jqgrid filtering, I wrote a code to filter my

  • 0

Looking at Oleg solution for jqgrid filtering, I wrote a code to filter my jqgrid. It has the difference to have 3 differents fields of research but only one button to execute the global search. It works quite good but even if the first search is executed correctly, the second search is executed 2 timese, the third search 4 times, the fourth 8 times and so on, causing several issues if I make a lot of searches.
Here’s the code:

var grid= $("#mygrid");

function executeSearchInSoftgrid() {    
$("#executeSearch").click(function() {
    f = {groupOp:"AND",rules:[]};
    var searchFiler = $("#filterField1").val(), f;
    var searchFiler2 = $("#filterField2").val(), f;
    var searchFiler3 = $("#filterField3").val(), f;
    if (searchFiler.length === 0) {
        grid[0].p.search = false;
        $.extend(grid[0].p.postData,{filters:""});
    }
    if (searchFiler2.length === 0) {
        grid[0].p.search = false;
        $.extend(grid[0].p.postData,{filters:""});
    }
    if (searchFiler3.length === 0) {
        grid[0].p.search = false;
        $.extend(grid[0].p.postData,{filters:""});
    }

    f.rules.push({field:"field1",op:"cn",data:searchFiler});
    f.rules.push({field:"field2",op:"cn",data:searchFiler2});
    f.rules.push({field:"field3",op:"cn",data:searchFiler3});
    grid[0].p.search = true;
    $.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
    grid.trigger("reloadGrid",[{page:1,current:true}]);
    alert("searching");
}); 

}

Wherever I call the function (loadcomplete, gridcomplete, readyfunction) the behaviour is the same. Any ideas???
Thanks

EDIT

Here’s the place where I call the function, and it finally works:

var initialize = true;
$("#mygrid")
        .jqGrid({
            gridComplete:function () {
                if(initialize == true) {
                executeSearchInSoftgrid();
                initialize = false;
                //....
                }
  • 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-08T16:45:16+00:00Added an answer on June 8, 2026 at 4:45 pm

    I suppose that the problem in your code is that you placed $("#executeSearch").click inside of executeSearchInSoftgrid function which you probably call more as one time. The code

    $("#executeSearch").click(function() {...});
    

    is nothing more as as registering of the event handler (the function function() {...}) which will be called automatically if the user click on the element having id="executeSearch". You can register multiple event handles to the click event. In the case all the callbacks will be called in the order in which there are registered.

    So you should register the callback function only once. If you would need the call the event handler independent from the user’s interaction you would can do this with $("#executeSearch").triggerHandler('click') (see here) or just with $("#executeSearch").click();.

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

Sidebar

Related Questions

Looking at some old code we have lots of things like the following: //
Looking at some assembly code for x86_64 on my Mac, I see the following
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking for best advice on how to do this: I have an insert like
Looking at some of the code System.Linq I've come across some examples of Buffer<TSource>
Looking around at different code bases I see a variety of styles: Class interfaces
Looking for a general case solution to determine if any jquery dialog (there are
Looking for opinions on if OpenCV could be or has been used to detect
Looking for good explanation of why this code raises SyntaxError . def echo(x): return
Looking at the following code, does theme[sprite].img get nested inside result[definition].data (as theme[sprite].img is

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.