Paul Davies
Top achievements
Rank 1
Paul Davies
asked on 21 Aug 2012, 08:46 AM
Hi,
I am trying to use the "Add new Record" button of the RadGrid to fire a confirmation message to our users. I have achieved this by capturing the event in RadGrid_ItemCommand method which works perfectly, but the edit form still shows even though I don't want it to.
Is there a way to hide/remove the edit form so that the users will not see it?
Thanks in advance,
Paul
I am trying to use the "Add new Record" button of the RadGrid to fire a confirmation message to our users. I have achieved this by capturing the event in RadGrid_ItemCommand method which works perfectly, but the edit form still shows even though I don't want it to.
Is there a way to hide/remove the edit form so that the users will not see it?
Thanks in advance,
Paul
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 21 Aug 2012, 09:36 AM
Hi,
You can pass the response from the RadConfirm using AjaxRequest and there by close the insert form.Here is the sample code snippet.
ASPX:
C#:
Javascript:
Thanks,
Shinu.
You can pass the response from the RadConfirm using AjaxRequest and there by close the insert form.Here is the sample code snippet.
ASPX:
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
OnAjaxRequest
=
"RadAjaxManager1_AjaxRequest"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadAjaxManager1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
></
telerik:RadWindowManager
>
C#:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.InitInsertCommandName)
{
RadWindowManager1.RadConfirm(
"Server radconfirm: Are you sure?"
,
"confirmCallBackFn"
, 330, 100,
null
,
"Server RadConfirm"
);
}
}
protected
void
RadAjaxManager1_AjaxRequest(
object
sender, AjaxRequestEventArgs e)
{
if
(e.Argument.ToString() ==
"cancel"
)
{
RadGrid1.MasterTableView.IsItemInserted =
false
;
RadGrid1.Rebind();
}
}
Javascript:
<script type=
"text/javascript"
>
function
confirmCallBackFn(arg)
{
var
ajaxManager = $find(
"<%=RadAjaxManager1.ClientID%>"
);
if
(arg)
{
ajaxManager.ajaxRequest(
'ok'
);
}
else
{
ajaxManager.ajaxRequest(
'cancel'
);
}
}
</script>
Thanks,
Shinu.
0
Martin Roussel
Top achievements
Rank 1
answered on 17 Oct 2012, 08:03 PM
Shinu,
im having the same question/request and you answer doesnt seem to solve the problem mentioned: How to avoid the grid's Edit mode to show when clicking on the button? I tried your snippet but edit mode still occurs.
TIA
im having the same question/request and you answer doesnt seem to solve the problem mentioned: How to avoid the grid's Edit mode to show when clicking on the button? I tried your snippet but edit mode still occurs.
TIA
0
Hello Paul,
You will need to use e.Canceled=true to prevent the automatic opening of the InitForm. You could also try the following approach:
JavaScript:
C#:
I hope this will prove helpful.
All the best,
Eyup
the Telerik team
You will need to use e.Canceled=true to prevent the automatic opening of the InitForm. You could also try the following approach:
<
asp:HiddenField
ID
=
"Confirmed"
runat
=
"server"
Value
=
"false"
/>
function
confirmCallBackFn(arg) {
if
(arg) {
$get(
"<%=Confirmed.ClientID%>"
).value =
true
;
$find(
"<%=RadGrid1.ClientID%>"
).get_masterTableView().fireCommand(
"InitInsert"
, ""
);
}
}
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName == RadGrid.InitInsertCommandName)
{
if
(Confirmed.Value !=
"true"
)
{
e.Canceled =
true
;
RadWindowManager1.RadConfirm(
"Open Insert Form?"
,
"confirmCallBackFn"
, 330, 100,
null
,
"Confirmation"
);
}
Confirmed.Value =
"false"
;
}
}
I hope this will prove helpful.
All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Martin Roussel
Top achievements
Rank 1
answered on 22 Oct 2012, 01:14 PM
Thanks Eyup, it works!