Forum
05:27
Hi Tony,
I'm trying to dynamically add data to the filterToolbar when a search is performed. I'm using dynatree next to my grid, and I need to add the selected tree node data to the search.
I've tried the following code for that:
.filterToolbar({
autosearch: true,
beforeSearch: function() {
// Add selected tree data to the grid search
var dtnode = $("#tetec_tree").dynatree("getActiveNode");
addGridSearchData(dtnode);
}
})
function addGridSearchData(dtnode) {
$('#all_tetecs .ui-search-toolbar').show();
if(dtnode != null) {
if(dtnode.data.level == 'county') {
$('#tetecGrid').setGridParam({ postData:{ a: 'getAllTetecs', group_id: dtnode.data.key }, search:true});
} elseif(...) {
...
}
}
}
But somehow it seems to clear my added postdata just before it performs the search. I can see it calls my functions and does the setGridParam properly using firebug, but the data that's posted is missing the extra values. Is there some extra filter added to only post the filterToolbar submitted search values? Is there some way I can add extra postdata to it?
Regards,
Lotte-Sara Laan
04:35
Moderators
30/10/2007
Hello,
IMHO the code is correct and it should work. Which version of jqGrid is used? Could you please send a link to the problem?
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.
08:32
Hi Tony,
I've been debugging it a little more and the follow seems to be my problem:
In the triggerSearch function, the 'beforeSearch' function is called at the start. When that's done, and my postdata is added, the triggerSearch function goes on checking the input fields of the filterToolbar. Since my custom added post data are also possible search options in the filterToolbar, but in this case are not filled in by the user but taken from the dynatree node, they get deleted from the postdata here:
v = $("input[name="+nm+"]",self).val();
if(v) {
sdata[nm] = v;
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
}
j++;
} else {
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
}
try {
delete gr.p.postData[this.index];
} catch(e) {}
}
I understand it is needed to clear possible old search data, but in this case it breaks my custom added data.
I found 2 possible solutions:
- Change the order of calling the 'beforeSearch' function and checking the search fields by calling the 'beforeSearch' after the check.
- Adding the search data to the search fields in the filterToolbar in my 'addGridSearchData' function instead of adding the data to the postData.
I would prefer option 1 since option 2 will look odd to the end user when they see data popping up all of a suddon in the filterToolbar fields while they didn't put it there themselves. I'm just not sure if it would create other problems when this order is changed in the code.
Best Regards
Lotte-Sara Laan
08:35
Oh, btw to answer your questions, I'm using the latest version of the grid (3.5.2) and it's a little bit hard to give you a link to the page since it's running in a development environment which is not accessable from the outside atm, but I can see if I can give you a working example if you'd like to see one.
08:13
Moderators
30/10/2007
Hello,
Thanks. I think that this have sense. Will be included in next commits in GitHub
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.
11:39
06/09/2009
Hi Tony,
I've downloaded 3.6 beta to check if anything has changed regarding this post, but the self.p.beforeSearch function is still being called before checking the user input data in the toolbar causing the custom added post data, having the same name as the columns in the search toolbar, to be deleted.
04:58
Moderators
30/10/2007
Hello,
Also added. Thanks for remind me.
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.
Most Users Ever Online: 715
Currently Online:
61 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