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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:59:50+00:00 2026-05-20T18:59:50+00:00

I am using the most excellent jqGrid plugin, and have found lots of help

  • 0

I am using the most excellent jqGrid plugin, and have found lots of help on this site by searching, but I have found a problem I cannot solve, or find a solution to. This will be my first post here.

I am using a filterToolbar to do some searching of my grid. Because of the nature of the back end I need to interact with, I am unanble to use the filters that jqGrid provides, and instead need to intercept the search and modify the postdata before submitting. I do this with the filterToolbar option “beforeSearch” like this:

$("#SC_grid").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn", beforeSearch: function() {
            var postData = $("#SC_grid").jqGrid('getGridParam','postData');
            var newPostData = '1=1';
            var searchData = jQuery.parseJSON(postData.filters);
            for (var iRule=0; iRule<searchData.rules.length; iRule++) {
                newPostData = newPostData + " AND " + searchData.rules[iRule].field + " LIKE '%" + searchData.rules[iRule].data + "%' ";
            }
            $("#SC_grid").jqGrid('setGridParam',{postData: { filter: newPostData, filters: ''} } );
            return false;
}});

This works great for me to build a portion of my select before submission.
I would also like to use the advanced search in the same way, but Cannot figure out how to intercept the POST before submission. There does not appear to be a beforeSearch() option abailable, and the afterShowSearch or onClose options dont have the right timings. ANy suggestions on how to proceed?

Mark

  • 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-20T18:59:50+00:00Added an answer on May 20, 2026 at 6:59 pm

    You are right, the current implementation of advanced searching of the jqGrid don’t have any events like beforeSearch. The new version of advanced searching which are full new written will have onSearch method which could you use. The method like beforeSearch will be fired before trigger("reloadGrid",[{page:1}]), but after the postData will be filled.

    The beforeSearch of the filterToolbar has one more interesting feature so you can stop the searching by returning the true value from the beforeSearch. So the beforeSearch can play validation role.

    In one my old answer I described an universal method which can be used for any kind of validation or postData modification. In the answer I show how one can subclass the reloadGrid event handler of jqGrid and stop reloading of the grid if needed. The demo shows this. In the same way here one could do any other modification of the data. It’s pity, but the answer will be very bad indexed and will not be fond on the most searching on the stackoverflow. So one don’t know it.

    In you case you need only to modify the postdata before submitting and don’t need to stop the grid reloading. So you can solve the problem using at least two standard jqGrid events: beforeRequest and serializeGridData. In both you can access the search (as this.p.search) and postData (as this.p.postData) parameters. The value of search parameter will be send to the server as _search and will be set to true if any of searching/filtering method are used. So inside of one from the event handler you can modify this.p.postData.

    Inside of serializeGridData you have even a way to define which data exactly will be send to the server without require to modify the data. The advantage is that if you open the advance searching dialog next time you will see (and can modify if needed) the last searching request.

    If you need to have the same implementation of beforeRequest or serializeGridData on many grids of your web site you can set your default implementation of the function with respect of $.jgrid.defaults:

    $.extend($.jgrid.defaults, {
             datatype: 'json', // overwrite default value of any jqGrid parameter
             serializeGridData: function(postData) {
                 // your implementation
             }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using Asynctask most of time, but in the current app the
I have been using the most excellent Accessorizer to auto-magically generate setters/getters for my
Im using Storyboard for most screens in my iPhone app. However, I have one
We're using Infragistics grid (most probably, we'll have 8.2 version at the end) and
Since 6 months I'm using the excellent Vim text-editor. The most interesting thing is
I have been using the excellent BizTalk Provider for PowerShell from Codeplex for a
After using the excellent Krumo package for PHP (perhaps most famous for its use
I am using the most excellent ant/bin/complete-ant-cmd.pl for bash completion of ant targets and
I have a number of student with java programming assigment written using (most probabaly)
I live and breathe jQuery, but I also love finding an excellent plugin that

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.