Forum


21:48

16/04/2009

I'm working on a jqGrid/bbq extension to integrate jqGrid paging with browser history. Works pretty well, but I don't like the design.
I wrote a jqGridWithHistory function that the user calls. This returns a grid with the history extension. So instead of calling:
$("#foo").jqGrid(opts);
You call:
$("#foo").jqGridWithHistory(opts);
Instead.
It would make more sense to me to make the history integration an option, e.g.:
$("#foo").jqGrid({ url: url, history: true, ... });
But I can't find an extension point in the grid source code which would allow this.
Essentially, I need to fiddle with the options before the grid is loaded, so that I can modify page, rowNum, and the like, if need be, and hook gridComplete. $.jgrid.default won't work because it's overwritten by options.
What would be ideal for me is if I could (inside my plugin) do something like:
$.jgrid.extend("beforeCreate", function() {
// run plugin code
});
Then inside the function I could look at the grid properties and modify them if need be, after they're set but before the grid data is fetched. Other plugins, of course, could do the same, and there would probably need to be many extension points.
Does anything like this already exist and I just missed it?
If not, consider this a feature request.
I'll share my plugin when I'm happy with the quality.
-Craig
13:52

Moderators
30/10/2007

Hello,
I'm not sure if this will do the job for you but there is exactley such event called beforeRequest - which is raised exactley before the request.
http://www.trirand.com/jqgridw.....iki:events
Also I think it is easy to do such things - if I understand right the problem:
var gridoptions = { url : "...", rowNum : 10,...}
if(some condition) {
gridoptions.rowNum = 20;
}
$("#mygrid").jqGrid(gridoptions);
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.
19:13

16/04/2009

Tony,
Thanks for responding, but that doesn't answer my question. I will try to clarify.
I know that there is a beforeRequest event, but to handle it I need to change options to include a handler for beforeRequest. So a user of my plugin could write:
$("#grid").jqGrid({ beforeRequest: function() { $.gridHistory(this) } });
...but that's an incredibly awkward way to use a "plugin", especially if the user is already hooking beforeRequest for something else.
I would prefer that the user could just write:
$("#grid").jqGrid({ history: true });
What I'm asking for, essentially, is a global beforeRequest handler (well, better still would be an event which ran once when the grid was created, not before every request -- but even a global beforeRequest is better than what I have now). One which always runs for all grids, not one specific grid. Like I said, it would go in the global $.jgrid rather than the grid-specific options object.
Does that make more sense?
Thanks,
-Craig
19:29

Moderators
30/10/2007

Hello,
this is maybe what you looking for:
$.extend($.jgrid.defaults,{...});
before creating a grid
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.
16:49

16/04/2009

tony said:
Hello,
this is maybe what you looking for:
$.extend($.jgrid.defaults,{...});
before creating a grid
Regards
Tony
That doesn't fix the problem. If the grid user binds beforeRequest, then my code doesn't run. Existing plugins (e.g., treegrid, subgrid) require modification of grid.base.js. to work. That's bad; the grid should not depend on its plugins. What if I could do:
(or other events). Then a plugin author could write a plugin which works without having to change grid.base.js for every plugin.
Most Users Ever Online: 715
Currently Online:
60 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