This is a migrated thread and some comments may be shown as answers.

Can I AJAXify the Delete button only, in a grid?

3 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Brent
Top achievements
Rank 1
Brent asked on 14 Nov 2008, 01:42 PM
Here is my scenario:
- I have a User Control and a RadGrid on a page.
- The RadGrid has and Add New link button in the CommandItemTemplate
- Each row in the grid has an Edit and a Delete Button.
- My entire Grid is ajaxified to update my user control as such:

            RadAjaxManager.AjaxSettings.AddAjaxSetting(DebtorsGrid, QueueItemDetailsUserControl);

- When the user Deletes a row in the grid, I run server side code that dynamically builds my user control (recreates all of the controls in the user control).
- I do NOT run that same code when a user does an Edit or an Add New in the grid, so the user control does not get updated.

- Currently, when the user Deletes a row from the grid, my code runs that rebuilds my user control, and after the ajax postback occurs, my user control is correctly updated / displayed.

My problem though is that when I do an Edit or an Add New in the grid, my control is empty after the postback.  Since I don't dynamically build it on Edit or Add New, I guess I lose the "state" of my user control.

My goal would be to ONLY ajaxify the grid's Delete button and my user control, rather than ajaxify the entire grid.
Is that possible?

Thanks,
Brent

3 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 18 Nov 2008, 07:21 AM
Hi Brent,

To see more information along the lines of the requested functionality, please refer to the following article, which represents one possible option.
I hope it gets you started properly.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Brent
Top achievements
Rank 1
answered on 18 Nov 2008, 09:19 PM
Thanks Yavor.  That article looked promising, but it didn't work for me.  I have many levels of nested user controls, and I think that causes a problem in my case.  Here was my code:

 

protected void DebtorsGrid_ItemCreated(object sender, GridItemEventArgs e)

 

{

 

    if (e.Item is GridDataItem)

 

    {

 

        GridDataItem item = (GridDataItem)e.Item;

 

 

        ImageButton DeleteImageButton = (ImageButton)item["DeleteButton"].Controls[0];

 

 

        RadAjaxManager ajaxManager = RadAjaxManager.GetCurrent(this.Page);

 

 

        UserControl IndexingPanel = (UserControl)this.Parent.Parent.Parent.Parent.FindControl("ucUCCIndexingPanel");

 

 

    
    ajaxManager.AjaxSettings.AddAjaxSetting(DeleteImageButton, IndexingPanel, null);

 

    }

}


The grid containing my DeleteButton is 3 levels deep in one user control.
While the IndexingPanel is 2 levels deep in an entirely different user control.

All of the above code ran fine, and my code that runs during a Delete from the grid runs fine, and the code that updated the IndexingPanel runs fine.  But when it has completed, the IndexingPanel is not visually updated.

Instead of adding the ajaxsettings in the ItemCreated of the grid (as show above), if I ajaxify the entire grid along with the IndexingPanel in the main aspx page (where my rad ajax manager is), then the IndexingPanel is updated correctly after all of the same code is run.

Thanks for the help.  I guess in my case, I'll just ajaxify the entire grid, which stinks, because then I have to run code that I don't want to run, when I do an Add New or Edit in the grid.

Thanks,
Brent
0
Yavor
Telerik team
answered on 19 Nov 2008, 07:25 AM
Hi Brent,

Another possible option may be to dynamically disable Ajax, for particular controls, while at the same time keeping the whole grid Ajaxified.

All the best,
Yavor
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Brent
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Brent
Top achievements
Rank 1
Share this question
or