Forum

November 2nd, 2014
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
Clear search values without reload grid
03/11/2009
05:17
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Hi everyone,

I'm trying to get my custom beforeSearch function working again with jqGrid 3.6 beta.

At some point, I need to be able to clear my previous search data and add custom data instead while I'm using the filterToolbar. There are two options I have:

Option 1:

var myGrid = $('#myGrid')[0];

myGrid.triggerToolbar();

This will trigger my beforeSearch function where I do something like this:

$('#myGrid').jqGrid('setGridParam',{ postData:{ a: 'getAllUnits', group_id: dtnode.data.key }, search:true });

The triggerToolbar function itself takes care of clearing old search data. The problem with this though, is that I manually add the group_id to the postdata instead of using the filterToolbar field for it and the triggerToolbar function does a little too much clearing now since it doesn't see any values in any of the toolbar fields and it will set my search value back to 'false' which is kinda in contradiction to the statement at the wiki:

"When this method is called a search is performed, the search parameter in grid becomes true and ajax call is made to the server"

The search paramater will only become true IF you actually have a value in any of the search fields...

Option 2:

var myGrid = $('#myGrid')[0];

myGrid.clearToolbar();

$('#myGrid').jqGrid('setGridParam',{ postData:{ a: 'getAllUnits', group_id: dtnode.data.key }, search:true });

$('#myGrid').trigger('reloadGrid');

Which of course will reload my grid twice which is not wat I want to do.

I'm not sure what exactly changed in the setGridParam or trigger reload function, because with version 3.5 I was able to do it like this:

$('#myGrid').jqGrid('setGridParam',{ postData:{ a: 'getAllUnits', group_id: dtnode.data.key }, search:true });

$('#myGrid').trigger('reloadGrid');

And no old search values would get posted.

So my question here is, how can I reload my grid with custom postvalues without posting previous search values with it? Or how can I clear the old search values without reloading my grid at the same time?

04/11/2009
04:30
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Yes thare are some changes in 3.6 - the events are called just before triggering. Also I have made some other things (not published jet) which will do the job. Note that the new thing are present into the docs.

look  here:

http://www.trirand.com/jqgridw....._searching

Look at events

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.

04/11/2009
06:52
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Hi Tony,

Thanks for your answer. I hadn't seen the "In this case you can construct your own search parameters and trigger the grid to search the data. Any other return value causes triggering." comments for the beforeSearch and beforeClear events.

I will try it out and see if it does the job for me ^^

04/11/2009
07:04
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Ok, I tried the following:

   ……

   .jqGrid('filterToolbar', {
     autosearch: true,
     beforeSearch: function() {
       // Add selected tree data to the grid search
       var dtnode = $(”#unit_tree”).dynatree(”getActiveNode”);
       addGridSearchData(dtnode);
       return true;
     },
     beforeClear: function() {
       // Add selected tree data to the grid search
       var dtnode = $(”#unit_tree”).dynatree(”getActiveNode”);
       addGridSearchData(dtnode);
       return true;
     } 
   })

   ……

But even though I'm returning 'true' the grid gets triggered and changes my custom set search:true gridparam to search:false and reloades my grid.

04/11/2009
23:24
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

Please read carfully what I write in my previous post -" Also I have made some other things (not published jet)...

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.

05/11/2009
02:58
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

Ok, didn't understand that you meant dat although the docs already describe the new functionality it wasn't yet released in the current beta version.

I'll wait till the next version is there then (-:

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

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

Hello,

You can test this in the 3.6RC. Also available for download from blog post

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.

12/11/2009
03:43
Avatar
lotjuh
Member
Members
Forum Posts: 28
Member Since:
06/09/2009
sp_UserOfflineSmall Offline

It works like a charm now! thx a lot again ^^

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
35 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