0

Is there anyway to validate the search field (I'm using custom search) before sending request to server? Validation is working fine with row editing and adding mode. Let say I want to search column price and error message should occur when user enters a text in search field. If search returns no data, I want to post a message on the screen. I see no events in search function that can get the server response. The onClose event happened when the search box is closed, but I don't know how to get the server response from this?

Another question, I've tried to use gridResize but it's not working, everything else is working just fine, I see no resize icon in bottom right corner. Please take a look at my code below:

jQuery("#list").jqGrid('gridResize',{minWidth:350,maxWidth:800,minHeight:80, maxHeight:350});

BenMorel
  • 34,448
  • 50
  • 182
  • 322
vuvan01
  • 21
  • 2

1 Answers1

0

The part of your question about the validation of the custom searching seems be the same which I answerd here. The answer include the demo where the validation of the 'Client' field is included.

How you can see, the custom searching is moved in the grid.addons.js module in the 4.0.0 version of jqGrid, so it can be removed in some later versions of jqGrid.

There are no special searching request to the server. There are exist just the standard request to fill the grid, where the _search parameter (corresponds to search parameter of jqGrid) are set to true and some other parameters like filters describe the filter criteria. So you can use emptyrecords parameter of jqGrid (see here). You can follow the demo (see the answer) which shows the message in the grid body.

You problems with gridResize seams me very easy. i suppose, that you either not included jQuery UI JavaScript (including of CSS only is not enough) or you placed call of gridResize in the wrong place. You don't posted the JavaScript code and the HTML code which could shows which JavaScripts files you have loaded and in which order. So I can not answer more exactly.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, thx for fast reponse. The test case I made is as follow: I load grid with some rows in it, then I perform the search that will result NO data from Database, I get error message in firefox "no element found", and my grid is still stay the same. But when my research return some data, these data will replace the existing data in the grid. I guess that's why I do not get the emptyrecords message when search return no data. What should I do now? – vuvan01 Apr 18 '11 at 10:29
  • Hi, I found solution myself, in server side, I should return the exact required data by jqgrid to show emptyrecords, before I just returned null from server. Anyway, thanks alot for your hint about using emptyrecords. About the search validation, I though there's built-in validion in JQGrid, but it's not, may be I'm just wait for the built-in function in JQGrid – vuvan01 Apr 18 '11 at 10:59
  • @vuvan01: You are welcome! I don't know that there are some plans to include search validation in the jqGrid, so if you need it you will have to implement it yourself. The validation of the searching could not work as other validation. For example if you "contain" or "start with" search operation for the column and for the column contain all strings must be at least 5 characters for example you should allow to enter less then 5 characters in the searching field. So the searching validation is really other as during editing. You can try to use http://docs.jquery.com/Plugins/validation. – Oleg Apr 19 '11 at 06:46