Forum


04:21

10/12/2010

Thanks for the GREAT product! Nice work.
I'm working on a custom implementation of the "undocumented" addfunc property for the NavGrid. Looking at the code that calls the user-defined addfunc (jqgrid.formedit.js):
.click(function(){
if (typeof o.addfunc == 'function') {
o.addfunc();
} else {
$($t).jqGrid("editGridRow","new",pAdd);
}
return false;
})
No parameters are passed into the user-defined function. However inside of my custom implementation for addfunc, I need to be able to reference the grid (automatic insert of new data or force entire grid to refresh, etc.). Inside the addfunc implementation, 'this' references the NavGrid object and I'm unable to find a way to reference the parent object (without using the #id attribute which as previously stated is dynamically generated and unknown at runtime). My solution to the problem was to modify the call to addfunc() so that the grid object is passed in as a parameter:
.click(function(){
if (typeof o.addfunc == 'function') {
o.addfunc($t);
} else {
$($t).jqGrid("editGridRow","new",pAdd);
}
return false;
})
That immediately solves my needs, however those customizations make it more difficult to upgrade jqGrid at a future date. Am I missing something (i.e. a way to reference the grid without knowing the #id) or can these changes be made upstream for future releases?
Hopefully I'm just being a jQuery/javascript novice and there is a simple solution.
Thanks
George
16:58

10/12/2010

The same would probably need to be done for the editfunc and delfunc:
if(typeof o.editfunc == 'function') {
o.editfunc(sr, $t);
} else {
$($t).jqGrid("editGridRow",sr,pEdit);
}
...
if("function" == typeof o.delfunc){
o.delfunc(dr, $t);
}else{
$($t).jqGrid("delGridRow",dr,pDel);
}
Although my requirements don't need it, applying the above to the beforeRefresh and afterRefresh might be warranted for API consistency:
if (o.refresh) {
...
if($.isFunction(o.beforeRefresh)) { o.beforeRefresh($t); }
...
if($.isFunction(o.afterRefresh)) { o.afterRefresh($t); }
...
}
18:57

10/08/2009

Hello George,
You are right, that it would be better to set this for the most callback functions. jqGrid in last versions made the corresponding changes in the most places, but not here. The usage of o.addfunc.call($t) instead of o.addfunc($t) seems me better because it set only this. If you want you can post the corresponding to "bugs" part of the forum.
If you need a solution now you can use custom button which look like the standard Add/Edit or Delete button and which has the same icon as the the original (see the source code of navGrid for details).
Best regards
Oleg
19:23

10/12/2010

Oleg
Yes, you're correct, the o.addfunc.call($t) would make more sense. I am aware of the custom button option and initially implemented it, but I wasn't happy with the button placement / look so that prompted me to browse the source where I found the undocumented addfunc, etc. calls. Implementing the custom addfunc90 seemed like a better option since the buttons were easily enabled / disabled and located in the correct position without having to tweak the ui, etc. I will make the changes you suggested with the assumption that the next release of jqGrid will implement them where this refers to the grid.
How do you want me to repost this in Bugs? Or can you just move this topic / thread into the bugs part of the forum? That would seem easier.
Thanks
George
20:15

10/08/2009

George,
first of all like you can see on the left side my status is "Member" like youth and not "Moderator" like the status of Tony, the developer of jqGrid. So I can not move your report if you can not do this. In the "Help" part of the forum some develpers who use jqGrid help other developers. So I suggested to post your suggestion in the "Bugs" forum to be sure that Tony read it and probably make the changes.
I send you the url to of the place of the source where you can see that Add button has "ui-icon-plus" as the icon. So the code like
{ caption: "", buttonicon: "ui-icon-plus", title: "Add new row",
onClickButton: function() {
var rowid = grid.jqGrid('getGridParam', 'selrow');
alert ("add operation with the rowid="+rowid);
}
});
includes the same button as the original Add button.
Best regards
Oleg
Most Users Ever Online: 715
Currently Online:
52 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