I have two grids, deleting an item from one grid pops up a radprompt for a deletion reason before a ajaxRequest is called to mark the record as deleted on the server. I then get both grids to rebind however the grids are then not being updated.
The AjaxManager declaration:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1"
EnableAJAX="True" onajaxrequest="RadAjaxManager1_AjaxRequest" >
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadGridInStock">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGridInStock" LoadingPanelID="RadAjaxLoadingPanel1" />
<telerik:AjaxUpdatedControl ControlID="RadGridDeleted" LoadingPanelID="RadAjaxLoadingPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
On the top grid is a column to trigger the delete:
<telerik:GridTemplateColumn UniqueName="DeleteLink">
<ItemTemplate>
<asp:LinkButton ID="DeleteLink" runat="server" Text="Delete" />
</ItemTemplate>
</telerik:GridTemplateColumn>
I associate the javascript with the column with this code:
protected void RadGridInStock_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
LinkButton button = item["DeleteLink"].Controls[1] as LinkButton;
APO_Vehicle vehicle = item.DataItem as APO_Vehicle;
if (vehicle != null)
{
button.Attributes.Add(
"onclick",
String.Format("return deleteClick({0});",
vehicle.Id));
}
}
}
This calls this javascript:
var deleteId;
function deleteClick(id) {
deleteId = id;
radprompt(
'What is your reason for deleting this car?', promptCallBackFn, 330, 100);
return false;
}
function promptCallBackFn(args) {
// Call an ajax method to delete the record
if (args != null && args.length > 0) {
var arguments;
arguments.id = deleteId;
arguments.reason = args;
$find(
"<%=RadAjaxManager1.ClientID%>").ajaxRequest('{ "id" : ' + arguments.id + ', "reason" : "' + arguments.reason + '" }');
}
}
The Ajax request code is as follows:
protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
{
// Code to delete record from db ..
RadGridInStock.Rebind();
RadGridDeleted.Rebind();
}
Is there a way to get the RadAjaxManager to update the grids from the AjaxRequest method? I kind of thought this should happen automatically.
Thanks,
Stuart