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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:54:03+00:00 2026-05-17T23:54:03+00:00

I have a search form I generated using the filterGrid option in JqGrid. I

  • 0

I have a search form I generated using the filterGrid option in JqGrid. I want to add a JavaScript logic which is invoked before I submit the Search form. I have added a method which is invoked by the beforeSubmit property for the filterGrid. It goes into the method before submitting, but always submits the form regardless of the value returned. I would like the form to not submit if the javascript returns false.

Have any of you guys implemented anything like this before. Or is there any othe rbetter way to implement this. Any help on this will be really appreciated.

Code:

$("#search").filterGrid("#resultsGrid",
                        {gridModel:true,gridNames:true,enableSearch:true,
                         formtype:"vertical",buttonclass:"submitButton",
                         enableClear:true,beforeSearch:validateDate});

function validateDate(dateDiff) {
    if(daysDiff < 0){
        return [false,"Message"];
    }
    } // ??? (commented by Oleg)
    return [true,""];
}
  • 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-17T23:54:04+00:00Added an answer on May 17, 2026 at 11:54 pm

    There are at least three different ways how searching can be used: Toolbar Searching, Custom Searching which you use and Single field searching or Advanced Searching which share the same code. So one have currently three different implementations of close things.

    Only Toolbar Searching has beforeSearch event handler which can return false to stop searching. In case of Custom Searching the value returned by the event handler beforeSearch will not used. Single field searching or Advanced Searching don’t call any event handler before searching. In all cases for the searching will set searching filter and the jqGrid parameter search to true and then force grid reloading with the code like

    $("#gridId").trigger("reloadGrid",[{page:1}]);
    

    To be able to make any validations and stop reloading of the grid I see no simple way. So I suggest only following.

    You can overwrite the standard reloadGrid event handler and chain it. The corresponding code con look like following:

    var grid = $("#gridId");
    var events = grid.data("events"); // read all events bound to 
    var originalReloadGrid; // here we will save the original event handle
    var skipRefresh = false; // this can be changed by owe validation function
    // Verify that one reloadGrid event hanler is set. It is typical sitation
    if (events && events.reloadGrid && events.reloadGrid.length === 1) {
        originalReloadGrid = events.reloadGrid[0].handler; // save old
        grid.unbind('reloadGrid');
        var newEvents = grid.data("events");
        grid.bind('reloadGrid', function(e,opts) {
            if (!skipRefresh && grid[0].p.search) {
                originalReloadGrid(e,opts);
            }
        });
    }
    

    Probably I will create later a demo which demonstrate this on an example and place the link to the demo here. Moreover I will try to suggest code changes to jqGrid so, that in all different implementations of searching will be possible to stop serching by returning false by beforeSearch event handle.

    UPDATED: OK! I prepared a demo for you. In the demo I use no server components, so it will not really do searching, but you can see the results if the grid will be refreshed and goes to the page 1.

    To test the demo you can do following:

    1. type in the “Client” input field a text not starting with ‘test’ and click “search” button. You receive an alert which simulate the validation dialog.
    2. type in the “Client” input field a text starting with ‘test’ like test1 and click “search” button. Now the grig will refreshed because the validation will be OK.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Using MySQL and PHP) I have a search form that will allow my users
I'm a RoR beginner and am using Rails 3.2.3. I have a search form
How do you add Search form to your Views in Drupal? Do I have
I have a form which I'm using jQuery to post and working to handle
I have a search form. I would like when someone type the term, first
I have a search form where user can search for products within their specified
I have a search form on my site that submits the url in the
I have a search form with min and max fields. It queries a MySQL
I have a simple search form with a box and a button. <form action
what I have: a google search form (displayed on all pages) a wordpress page

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.