Cory Benjamin
Top achievements
Rank 2
Cory Benjamin
asked on 13 Jun 2008, 07:25 AM
I have an AJAX enable RadGrid. One of the columns in this grid is a GridButtonColumn. I want to do a regular postback when this button is clicked because it initiates a file download.
I thought I could use client side java script to disable AJAX on this call, but I am having trouble identifying whether the button was clicked or not. Here's what I have so far:
In the grid:
I thought I could use client side java script to disable AJAX on this call, but I am having trouble identifying whether the button was clicked or not. Here's what I have so far:
In the grid:
<telerik:GridButtonColumn ButtonType="PushButton" UniqueName="Download" CommandName="Download" Text="Download"></telerik:GridButtonColumn>
In the AJAX Manager:<
ClientEvents OnRequestStart="mngRequestStarted" />
Client side java script<script type="text/javascript">
function mngRequestStarted(ajaxManager, eventArgs)
{
var re = new RegExp("\.DownloadButton$","ig");
if (eventArgs.EventTarget.match(re))
{
eventArgs.EnableAjax = false;
}
}
</script>
Everything seems to work except the regular expression check. I was hoping that the button controls would be named DownloadButton* (based on the UniqueName), but instead they are named like clt00$ContentPlaceHolder1$RadGrid1$ctl00$ctl04$ctl00. Any suggestions on how I can make this work? Thanks.
7 Answers, 1 is accepted
0
Hi Cory,
Thank you for the detailed explanation.
Indeed the id of the button inside the GridButtonColumn will be auto-generated and you will not be able to identify it with this approach using a regular expression.
Instead I suggest you replace the GridButtonColumn with GridTemplateColumn with buttton inside it which has explicitly set id and CommandName (for example id = "DownloadButton" and CommandName ="Download"). Thus you will be able to determine the button click and disable the ajax with the code you pasted in the thread.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Thank you for the detailed explanation.
Indeed the id of the button inside the GridButtonColumn will be auto-generated and you will not be able to identify it with this approach using a regular expression.
Instead I suggest you replace the GridButtonColumn with GridTemplateColumn with buttton inside it which has explicitly set id and CommandName (for example id = "DownloadButton" and CommandName ="Download"). Thus you will be able to determine the button click and disable the ajax with the code you pasted in the thread.
Best regards,
Stephen
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 11 Jul 2008, 10:19 AM
Hi!
Did you check if the onrequeststart event is fired?
I have exactly the same problem, but here I don't even reach the "OnRequestStart" method when clicking on and buttoncolumn.
could you please try that (e.g. by using some alert(args.TargetEvent) or something) ?
Thx in advance & kind regards - in the meantime i'll use my temlate column ;)
Did you check if the onrequeststart event is fired?
I have exactly the same problem, but here I don't even reach the "OnRequestStart" method when clicking on and buttoncolumn.
could you please try that (e.g. by using some alert(args.TargetEvent) or something) ?
Thx in advance & kind regards - in the meantime i'll use my temlate column ;)
0
Hi Markus,
I double tested the proposed setup.
The client side handler is properly raised, but the client id which is generated, and which is returned as the event target for the method, is something line "RadGrid1$ctl00$ctl04$ctl00" - thus the regular expression will fail and the ajax will not be disabled as expected.
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I double tested the proposed setup.
The client side handler is properly raised, but the client id which is generated, and which is returned as the event target for the method, is something line "RadGrid1$ctl00$ctl04$ctl00" - thus the regular expression will fail and the ajax will not be disabled as expected.
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Markus
Top achievements
Rank 2
answered on 11 Jul 2008, 11:46 AM
Alright, thank you.
I'll add this thing to my sampleproject which I handed in as support ticket the other day.
Maybe it's again an issue with detailtables and containing controls that have a ridgrid inside ?!?!....
We'll see... ticket id was: 148821
perhaps you can test it in this application when adding a radgrid with a buttoncolumn to the control in the detailtable
kind regards
I'll add this thing to my sampleproject which I handed in as support ticket the other day.
Maybe it's again an issue with detailtables and containing controls that have a ridgrid inside ?!?!....
We'll see... ticket id was: 148821
perhaps you can test it in this application when adding a radgrid with a buttoncolumn to the control in the detailtable
kind regards
0
Hello Markus,
This is actually part of the mechanism the client id is built. It cannot be altered - one alternative is to use the template column as mentioned earlier.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
This is actually part of the mechanism the client id is built. It cannot be altered - one alternative is to use the template column as mentioned earlier.
Sincerely yours,
Yavor
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
Marty
Top achievements
Rank 1
answered on 10 Dec 2008, 01:06 PM
Hi,
I'm trying to do the exact same thing as the original poster, but am doing so with a grid embedded in a RadPanelBar. I'm trying to go with the suggested work around for performing a full postback on a button contained within a grid on an ajaxified form. I've replaced my GridButtonColumn with a GridTemplateColumn and added a button with a specific ID in the ItemTemplate tag. My question is, how do I go about getting reference to the LinkButton object within my ItemTemplate when the grid itself is embedded in a RadPanelBar?
I've tried all of the following to no avail (all end up returning a null reference):
The relevant aspx code is as follows:
Any help is appreciated, thanks.
Marty
I'm trying to do the exact same thing as the original poster, but am doing so with a grid embedded in a RadPanelBar. I'm trying to go with the suggested work around for performing a full postback on a button contained within a grid on an ajaxified form. I've replaced my GridButtonColumn with a GridTemplateColumn and added a button with a specific ID in the ItemTemplate tag. My question is, how do I go about getting reference to the LinkButton object within my ItemTemplate when the grid itself is embedded in a RadPanelBar?
I've tried all of the following to no avail (all end up returning a null reference):
((LinkButton)RadPanelBar3.FindItemByValue("SuppDocs").FindControl("GrdDocs").FindControl("btnSave")).UniqueID |
((LinkButton)RadPanelBar3.FindItemByValue("SuppDocs").FindControl("GrdDocs").TemplateControl.FindControl("btnSave")).UniqueID |
((LinkButton)RadPanelBar3.FindItemByValue("SuppDocs").FindControl("GrdDocs").TemplateControl.FindControl("colSave").FindControl("btnSave")).UniqueID |
The relevant aspx code is as follows:
<telerik:RadPanelBar runat="server" ID="RadPanelBar3" Skin="Default" EnableEmbeddedSkins="True" |
Width="740px"> |
<CollapseAnimation Duration="100" Type="None" /> |
<Items> |
<telerik:RadPanelItem Enabled="true" Expanded="true" runat="server" Font-Bold="True" |
Text="Supporting Documentation"> |
<Items> |
<telerik:RadPanelItem runat="server" Value="SuppDocs"> |
<ItemTemplate> |
<table> |
<tr> |
<table> |
<tr> |
<td> |
<telerik:RadGrid ID="GrdDocs" runat="server" GridLines="None" ShowGroupPanel="True" |
AutoGenerateColumns="False" AllowPaging="True" OnNeedDataSource="GrdDocs_OnNeedDataSource" |
OnUpdateCommand="GrdDocs_ViewSelected" OnDeleteCommand="GrdDocs_OnDelete"> |
<HeaderContextMenu EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</HeaderContextMenu> |
<MasterTableView DataKeyNames="DocumentID"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="DocumentID" EmptyDataText="&nbsp;" HeaderText="Document ID" |
UniqueName="column" Visible="False"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="FileName" EmptyDataText="&nbsp;" HeaderText="File Name" |
UniqueName="column1"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="DateUploaded" EmptyDataText="&nbsp;" HeaderText="Date Uploaded" |
UniqueName="column2"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="AddedBy" EmptyDataText="&nbsp;" HeaderText="Added By" |
UniqueName="column3"> |
</telerik:GridBoundColumn> |
<telerik:GridButtonColumn ButtonType="LinkButton" Text="Delete" UniqueName="colDelete" |
CommandName="Delete"> |
</telerik:GridButtonColumn> |
<telerik:GridTemplateColumn HeaderText="Save/View" UniqueName="colSave"> |
<ItemTemplate> |
<asp:LinkButton ID="btnSave" runat="server" OnCommandName="Update" Text="Save/View" /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
</Columns> |
</MasterTableView> |
<FilterMenu EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
</telerik:RadGrid> |
</td> |
</tr> |
</table> |
</td> |
</tr> |
</table> |
</ItemTemplate> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelItem> |
</Items> |
</telerik:RadPanelBar> |
Any help is appreciated, thanks.
Marty
0
Hi Marty,
To reference the button inside the template column in the grid, you will need to reference a particular grid row which hosts it, for example:
Then you can pass the UniqueID of the control on the client to disable the ajax explicitly when the button is clicked. Alternatively, create an appropriate regular expression on the client which matches part of the unique id of the button, i.e.:
Best regards,
Sebastian
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
To reference the button inside the template column in the grid, you will need to reference a particular grid row which hosts it, for example:
((LinkButton)RadPanelBar3.FindItemByValue("SuppDocs").(CType("GrdDocs"), RadGrid).MasterTableView.Items[0].FindControl("btnSave")).UniqueID |
Then you can pass the UniqueID of the control on the client to disable the ajax explicitly when the button is clicked. Alternatively, create an appropriate regular expression on the client which matches part of the unique id of the button, i.e.:
<script type="text/javascript"> |
function mngRequestStarted(ajaxManager, eventArgs) |
{ |
var re = new RegExp("\.btnSave$","ig"); |
if (eventArgs.EventTarget.match(re)) |
{ |
eventArgs.EnableAjax = false; |
} |
} |
</script> |
Best regards,
Sebastian
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.