Forum


05:17

06/09/2009

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:
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:30

Moderators
30/10/2007

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.
06:52

06/09/2009

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 ^^
07:04

06/09/2009

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.
23:24

Moderators
30/10/2007

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.
10:06

Moderators
30/10/2007

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.
Most Users Ever Online: 715
Currently Online:
84 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66