The process I was told to use for this with 'classic' controls was to use something like this ...
Is this still the preferred mechanism for doing with when using AJAX Grid and ToolBar?
--
Stuart
| void Grid_ItemCreated(object sender, GridItemEventArgs e) { |
| if(e.Item is GridCommandItem) { |
| GridCommandItem ci = e.Item as GridCommandItem; |
| ci.Controls.Clear(); |
| ci.Controls.Add(new TableCell()); |
| ci.Cells[0].Controls.Add(CreateCommandItemTemplate()); |
| } |
| } |
--
Stuart
16 Answers, 1 is accepted
0
Hi Stuart,
A possible approach would be to add a container like a PlaceHolder in the CommandItemTemplate and use it to add your controls there. Take a look at the second Grid and its ItemCreated implementation here:
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Programming/AlphabeticPaging/DefaultCS.aspx
All the best,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
A possible approach would be to add a container like a PlaceHolder in the CommandItemTemplate and use it to add your controls there. Take a look at the second Grid and its ItemCreated implementation here:
http://www.telerik.com/demos/aspnet/prometheus/Grid/Examples/Programming/AlphabeticPaging/DefaultCS.aspx
All the best,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 1
answered on 18 Apr 2008, 06:58 AM
Konstantin,
Thanks for the reply.
I can see what you're getting at, but the whole grid is created programmatically. Sorry if I didn't make that clear.
I'm generating the grid (and lots of other controls) from the ground up.
--
Stuart
Thanks for the reply.
I can see what you're getting at, but the whole grid is created programmatically. Sorry if I didn't make that clear.
I'm generating the grid (and lots of other controls) from the ground up.
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 18 Apr 2008, 09:07 AM
I've just realised that I need to override the Render event in the CommandItem to add some JS, so I'm going to have to at least try and use the old method, 'cos I'm going to need to add the CommandItem as a Control (which I can override th Render event of) rather than an ITemplate.
Unless, of course, you know different.
--
Stuart
Unless, of course, you know different.
--
Stuart
0
Hi Stuart,
Did you manage to add the toolbar within the Grid CommandItemTemplate successfully? I'm not sure whether the old technique can cause any problems, just gave you an alternative approach.
Once you got that working, you can share the solution with the community.
Kind regards,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Did you manage to add the toolbar within the Grid CommandItemTemplate successfully? I'm not sure whether the old technique can cause any problems, just gave you an alternative approach.
Once you got that working, you can share the solution with the community.
Kind regards,
Konstantin Petkov
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 1
answered on 22 Apr 2008, 02:36 PM
Konstantin,
Am battling with something else ATM.
Will report back shortly.
--
Stuart
Am battling with something else ATM.
Will report back shortly.
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 23 Apr 2008, 03:32 PM
Konstantin,
Because of the new client API I've been able to do away with much of the code I had for handling the old classic control.
The upshot is that I am back to being able to just use a regular template, albeit a programmatically created one.
I do have a follow up question though.
Let's assume I've got a page that I've programmatically created 2 different grids on. Each grid has a ToolBar as the CommandItem and each, say, has a button for Export to PDF.
I need to know which grid the the button is attached to so I can call the method against the correct grid. I don't really mind whether the export is triggered from the client or serverside.
Can you offer a pointer?
--
Stuart
Because of the new client API I've been able to do away with much of the code I had for handling the old classic control.
The upshot is that I am back to being able to just use a regular template, albeit a programmatically created one.
I do have a follow up question though.
Let's assume I've got a page that I've programmatically created 2 different grids on. Each grid has a ToolBar as the CommandItem and each, say, has a button for Export to PDF.
I need to know which grid the the button is attached to so I can call the method against the correct grid. I don't really mind whether the export is triggered from the client or serverside.
Can you offer a pointer?
--
Stuart
0
Accepted
Hi Stuart,
The cleanest solution might be to set CommandName = "ExportToPdf" for the respective RadToolBar button. Thus the event bubblilng mechanism of RadGrid will be automatically triggered and the export operation will be processed for the grid instance holding the relevant toolbar control. I hope this makes sense.
Best,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The cleanest solution might be to set CommandName = "ExportToPdf" for the respective RadToolBar button. Thus the event bubblilng mechanism of RadGrid will be automatically triggered and the export operation will be processed for the grid instance holding the relevant toolbar control. I hope this makes sense.
Best,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 12:18 PM
Thanks Stephen,
I'm having a few problems trying to implement this. The Grid that I'm creating is, itself, the child of an AjaxPanel and this is bringing problems of its own (namely, the events don't seem to bubble).
I've had to raise a ticket for this (#134163, if you're interested) because I've come to a complete stop.
--
Stuart
I'm having a few problems trying to implement this. The Grid that I'm creating is, itself, the child of an AjaxPanel and this is bringing problems of its own (namely, the events don't seem to bubble).
I've had to raise a ticket for this (#134163, if you're interested) because I've come to a complete stop.
--
Stuart
0
Hello Stuart Hemming,
Since export with ajax enabled is not possible, review the online resources linked below which demonstrate how to proceed in such situation (namely, disable the ajax explicitly before the export action takes place):
http://www.telerik.com/help/radcontrols/prometheus/?grdExportWithAJAX.html
http://www.telerik.com/community/code-library/submission/b311D-ttcbe.aspx
Regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Since export with ajax enabled is not possible, review the online resources linked below which demonstrate how to proceed in such situation (namely, disable the ajax explicitly before the export action takes place):
http://www.telerik.com/help/radcontrols/prometheus/?grdExportWithAJAX.html
http://www.telerik.com/community/code-library/submission/b311D-ttcbe.aspx
Regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 12:41 PM
Since export with ajax enabled is not possible
I didn't know that.
There is just so much of this stuff to get through! It'll be months before I've got to grips with it!
Thanks for the pointers to the online articles. I'm checking 'em out now.
--
Stuart
I didn't know that.
There is just so much of this stuff to get through! It'll be months before I've got to grips with it!
Thanks for the pointers to the online articles. I'm checking 'em out now.
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 12:47 PM
It wouldn't hurt for those example to use a RadAjaxPanel rather than an ASP UpdatePanel.
--
Stuart
--
Stuart
0
Hello Stuart,
Correct me if I am wrong but the sample projects from the code library thread cover all possible scenarios (Grid ajaxified by RadAjaxManager/RadAjaxPanel, in master page context, and export from ajaxified context menu).
Best,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Correct me if I am wrong but the sample projects from the code library thread cover all possible scenarios (Grid ajaxified by RadAjaxManager/RadAjaxPanel, in master page context, and export from ajaxified context menu).
Best,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 01:01 PM
You're right, I missed one.
--
Stuart
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 01:26 PM
I seem to be going around in circles.
in the online examples you pointed me at, you can tell what the control is that's caused the AjaxRequest because you have a fixed list to test against. My caller is a toolbar button in a programmatically generated template used on a programmatically created grid.
I hate my life.
--
Stuart
in the online examples you pointed me at, you can tell what the control is that's caused the AjaxRequest because you have a fixed list to test against. My caller is a toolbar button in a programmatically generated template used on a programmatically created grid.
I hate my life.
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 02:02 PM
OK. This is the best I've been able to do, I'd appreciate a pointer if there's a better way of doing it.
In my Template creation code, I've added a custom attribute to the ToolBar ...
Then, in my page I'm catching the AjaxRequestStart event with this function ...
Obviously, this'll turn any CommandItem request into a PostBack, but I can add additional checks if that becomes an issue.
--
Stuart
In my Template creation code, I've added a custom attribute to the ToolBar ...
| void ITemplate.InstantiateIn(Control container) { |
| RadToolBar tb = new RadToolBar(); |
| tb.ButtonClick += new RadToolBarEventHandler(tb_ButtonClick); |
| tb.Skin = "Hay"; |
| tb.ID = "ci"; |
| tb.Attributes["commanditem"] = "true"; |
| ... |
| function APRequestStart(sender, args) { |
| var target = args.EventTargetElement; |
| var attributes = target.control.get_attributes(); |
| if (attributes != null) { |
| var ci = attributes.getAttribute("commanditem"); |
| if (ci != null && ci == "true") args.set_enableAjax(false); |
| } |
| } |
--
Stuart
0
Dan
Top achievements
Rank 1
answered on 24 Apr 2008, 02:44 PM
With the fudge flavoured code I've put in place to cancel the AjaxRequest, I've got the event bubbling working.
Many thanks for persevering with this for me Stephen.
I would, of course, still like to hear any thoughts you may have on the issue of identifying the source of the AjaxRequest.
--
Stuart
Many thanks for persevering with this for me Stephen.
I would, of course, still like to hear any thoughts you may have on the issue of identifying the source of the AjaxRequest.
--
Stuart