I'd like to use an AjaxGrid to display some tabular information instead of brewing my own widget, but I'm having trouble figuring out whether it can do what I want, and how.
What I'd like to do is have a page with a selection box and an AjaxGrid. The selection box gets populated dynamically through AJAX, and I'd like the AjaxGrid to be redisplayed whenever a user selects an option from the selection box. For this I need to somehow pass a parameter to my json refresh method that supplies the data to the AjaxGrid.
Is it possible to somehow pass a parameter like this? I've seen how you can set a parameter in the refresh url in the constructor for the AjaxGrid, but that's not really useful for me here, since I don't know the parameter value until the user selects an option.
> I'd like to use an AjaxGrid to display some tabular information > instead of brewing my own widget, but I'm having trouble figuring > out whether it can do what I want, and how.
> What I'd like to do is have a page with a selection box and an > AjaxGrid. The selection box gets populated dynamically through > AJAX, and I'd like the AjaxGrid to be redisplayed whenever > a user selects an option from the selection box. For this I need to > somehow pass a parameter to my json refresh method that supplies > the data to the AjaxGrid.
> Is it possible to somehow pass a parameter like this? I've seen how > you can set a parameter in the refresh url in the constructor for > the AjaxGrid, but that's not really useful for me here, since I > don't know the parameter value until the user selects an option.
So after a whole bunch of poking around I figured it out, and I'll probably be writing it up. Is there any particular place that I can submit a tutorial on how to use AjaxGrid to the docs?
And also another related question about AjaxGrid. How do I set rows to be a link, or at the very least hang an 'onclick' action on them? There seems to be something possible with the 'actions' parameter to the grid, but it's not trivial to figure out from the code, and I'm wondering if its use is documented somewhere.
> So after a whole bunch of poking around I figured it out, and I'll > probably be writing it up. Is there any particular place that I can > submit a tutorial on how to use AjaxGrid to the docs?
I guess the Wiki is the appropriate place.
> And also another related question about AjaxGrid. How do I set rows > to be a link, or at the very least hang an 'onclick' action on them? > There seems to be something possible with the 'actions' parameter to > the grid, but it's not trivial to figure out from the code, and I'm > wondering if its use is documented somewhere.
>> So after a whole bunch of poking around I figured it out, and I'll >> probably be writing it up. Is there any particular place that I can >> submit a tutorial on how to use AjaxGrid to the docs?
> I guess the Wiki is the appropriate place.
>> And also another related question about AjaxGrid. How do I set rows >> to be a link, or at the very least hang an 'onclick' action on them? >> There seems to be something possible with the 'actions' parameter to >> the grid, but it's not trivial to figure out from the code, and I'm >> wondering if its use is documented somewhere.
> On 27-Nov-06, at 2:50 PM, Diez B. Roggisch wrote:
>>> So after a whole bunch of poking around I figured it out, and I'll >>> probably be writing it up. Is there any particular place that I can >>> submit a tutorial on how to use AjaxGrid to the docs? >> I guess the Wiki is the appropriate place.
>>> And also another related question about AjaxGrid. How do I set rows >>> to be a link, or at the very least hang an 'onclick' action on them? >>> There seems to be something possible with the 'actions' parameter to >>> the grid, but it's not trivial to figure out from the code, and I'm >>> wondering if its use is documented somewhere.
> I'm a bit confused here, what is columnobject in this instance?
Argl. I'm sorry, that was targeted towards the DataGrid widget. Sorry for causing confusion.
But I had a look into the sourcecode - so it appears that one can return actions to call in the json data. See widget.js - it looks somewhat more complicated than I can now parse without having a use case on my own.
> And also another related question about AjaxGrid. How do I set rows > to be a link, or at the very least hang an 'onclick' action on > them? There seems to be something possible with the 'actions' > parameter to the grid, but it's not trivial to figure out from the > code, and I'm wondering if its use is documented somewhere.
I've tried doing this by passing an 'actions' parameter to the widget and I did a little bit farther along but I could only do this by hacking the ajaxgrid.js file itself.
AjaxGrid.prototype.refresh does an eval() on the parameters it sends to the server-side refresh method, however AjaxGrid.prototype.updateGrid doesn't, and just sends the response it gets to Widget.grid.render. The problem with this is that Widget.grid.renderRows (called from Widget.grid.render) does the following:
var actions = Widget.exists(content.actions)? content.actions:{}; ... var p = actions.select.params.concat(row_id);
The problem here is that actions.select.params.concat can't possibly be a JS function because it's just the stuff returned as JSON from the server, so this always fails. Similar stuff is done in Widget.grid.renderRowActionsLink.
The only way I could make this work is by putting this in ajaxgrid.js: response.actions.select.params.concat = eval (response.actions.select.params.concat); which turns it into a function which can then be applied to an argument. This is obviously not a very good solution because we then need to check and eval every possible function that we're given in ajax grid, maybe this logic belongs in the place that calls these functions? Or maybe I'm just misunderstanding how I'm supposed to use these functions, in which case please do correct me. :-)