Reason: I am using a custom confirmation box and if the user selects YES from the radwindow,
Method : I use a javascript function to do an ajaxrequest.
Issue: The item gets deleted however the grid doesn't rebind
Code:
<telerik:RadCodeBlock ID="RadCodeBlockConfirm" runat="server">
<script type="text/javascript" language="javascript">
function 'confirmDelete() {
try {
//opening a confirm box
var oWnd = radopen("Confirm.aspx?prompt=Do you want to delete the selected item?", "ConfirmDelete");
}
catch (err) {
}
return false;
}
function ConfirmResponse(tag, value) {
try {
//User selected YES
if (value == "Yes") {
confirmHandler(value);
}
}
catch (err) {
}
}
function confirmHandler(arg) {
try {
if (arg) {
$find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Delete");
}
}
catch (err) {
}
}
</script>
</telerik: >
<SomeRadGrid>
<CommandItemTemplate>
<asp:LinkButton CssClass="CommandItemButton" ID="DeleteButton" OnClientClick='confirmDelete();'
runat="server" Text="Delete" ></asp:LinkButton>
</CommandItemTemplate>
</SomeRadGrid>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager_OnAjaxRequest">
<AjaxSettings>
//update....
</AjaxSettings>
</telerik:RadAjaxManager>
///////////////////////////////////////////
CODE BEHIND
/////////////////////////////////////////////
protected
void RadAjaxManager_OnAjaxRequest(object sender, AjaxRequestEventArgs e)
{
if (e.Argument.Equals("Delete"))
{
// Delete Item from SomeRadGrid
SomeRadGrid.Rebind(); // This looks like it is rebinding , it goes in to the need datasource and the item seems to be removed however Untill I hit refresh from the Grid It doesn't update the view
}
}
It looks like rebind doesn't update the view on
I also tried this .......
function RefreshGrid(ID) {
setTimeout("RefreshGrid('<%= SomeRadGrid.ClientID %>')", 200);
var masterTable = $find(ID).get_masterTableView();
masterTable.rebind();
}
This does rebind but I had to use a settimeout to slow it down so it doesn't rebind before the item is deleted. THis seems very unsafe and doesn't work in all cases like with more that 10 items.
Could you share a better approach.
AS a summary:
All I need is an ability to rebind after an ajaxrequest. I have to use a custom confirm box that will have to do an ajax request to delete an Item on the parent page, then i need to rebind.
Doing a radgrid.Rebind(); on the server in the onajaxrequestevent does rebind but the view does not change.
Thanx for the help!