Forum

July 12th, 2025
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Multisearch - restricting additional search criteria
05/10/2009
06:41
Avatar
Arun
Member
Members
Forum Posts: 3
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

Hello,

I have included multisearch facility into the jqGrid.  I would like to restrict the number of additional (search criteria) the user adds, say the maximum of 5 times.  Is there a way to put a restriction?.

Please Help.

Arun
06/10/2009
06:19
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

5 times or 5 items - it is not the same

Both are not supported.

Reagrds

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

20/10/2009
05:47
Avatar
Arun
Member
Members
Forum Posts: 3
Member Since:
05/10/2009
sp_UserOfflineSmall Offline

Hi Tony,

First, thanks for your reply and all the hard work put in to develop such a awesome tool.  I was able to restrict the number of searches allowed in a multi-search option. I have modified the code to put a restriction to the maximum number of times the search row being added. Hope it might be useful to someone….

Here is how I have done:

In JQGrid Version 3.5 – Advanced Searching option demo, you can have n number of search rows by clicking on '+'.

This has been modified as below, where you can restrict the number of search rows being added based on the maxMSCount defined. Once the search rows reaches the max count, it will not allow the user to add any more rows.
I have tried the way as explained below, which is working.

As a first step, I have defined a property 'maxMsCount' (maximum multi search count), under multisearch options.
say for example: maxMsCount: 3

This maxMsCount property value will be used to restrict the number of search rows being added by clicking on '+'.

In order to identify the number of search rows added, I have added an id (id='sf') to the tbody tag of <div id=”fbox_list”.  So that on every click on '+' (plus), I can get the count and restrict the number of search rows been added (here every search row is basically a tr tag).

The condition checked for restricting the search rows is would look like :
if (tr.size > __maxMsCount) return; //just returns without adding the new search row

Where __maxMSCount holds the value of maxMsCount option which is defined under multisearch options.

STEPS TO IMPLEMENT THIS
1. The grid definition
jQuery(”#samplelist”).jqGrid({
        url: '…
        .
        .
        }).navGrid('#navigatorBar',{edit:false,add:false,del:false},//nav options
            {},//edit options
            {},//add options
            {},//del options
            {multipleSearch:true,maxMsCount:3,…..}, //search options
            {} //view options
        ); // End Of navGrid
});

2. The code modification required under
jquery.jqGrid.min.js

2.1 Added the below variable in the js file
var __maxMsCount=-1;

2.2 Then assigned the maxMsCount option value to __maxMsCount
__maxMsCount=(c.maxMsCount?c.maxMsCount:); //assignes if maxMsCount is defined

2.3 Then the condition to restrict the maxMsCount if maxMsCount property is present under search options.
if (__maxMsCount>0){
    if ($('#sf > tr').size()>__maxMsCount)return;
}
Where 'sf' is the id of tbody tag, and $('#sf > tr').size() gives the number of tr's under tbody tag.

Thanks and Regards

Arun

21/10/2009
05:11
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

Thanks, will consider this feature.

Best Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 994

Currently Online:
39 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information