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

[Solved] Grids, Panels, and AjaxManager

4 Answers 153 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lyn Mannato
Top achievements
Rank 1
Lyn Mannato asked on 19 Jun 2008, 07:44 PM
Hello,

I have a page that has 2 grids and an asp:panel that contains various controls including a button.  When the page first loads only the 2 grids are visible.  When the user clicks a button command in grid1, I want to display the panel and hide grid2 such that only grid1 and the panel are visible.  When the user clicks a "cancel" button in the panel, I want to hide the panel and redisplay grid2 such that only the 2 grids are visible.  I want similar behavior when the user clicks a button command in grid2 i.e. I want to display the panel and hide grid1.  When they click the "cancel" button in the panel, I want the panel to be hidden and grid2 redisplayed.

I am using RadGrids and a RadAjaxManager.  The grids have been added through the designer, but the columns are programmatically created.

When I click the button command in grid1, the panel will display, but grid2 will not hide, yet if I click something in grid2 with the panel visible, grid2 will disappear and never come back.  Same thing happens if I start with the grid2 button command.  The panel will display, but grid1 won't disappear, yet if I click something in grid1 it will disappear and never come back.

The button command in grid1 makes a call to a function that does this:

aspPanel.Visible =

true;

grid2.Visible =

false;

The button command in grid2 makes a call to function that does this:

aspPanel.Visible = true;

grid1.Visible =

false;

The button command in the asp:panel makes a call to a function that does this:

// hide the panel

aspPanel.Visible =

false;

// show all the grids

grid1.Visible = true;

grid2.Visible =

true;

I'm thinking it has something to do with how I configure the AjaxManager so here is how I have it set up right now:

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, grid1);

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, grid2);

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, aspPanel);

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, aspPanel);

Any help would be greatly appreciated.
Thanks!
Lyn

4 Answers, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 20 Jun 2008, 08:08 PM
Hello Lyn,

I'd be happy to help you with your problem. However, I am having a difficult time following what you are trying to do. Would you mind posting a more complete example of your code? I would be glad to take a closer look so that I can help you solve this problem.

Sincerely,
Kevin Babcock
0
Lyn Mannato
Top achievements
Rank 1
answered on 20 Jun 2008, 08:17 PM
Sorry, I will make it a bit simpler.

I have 2 grids.  Grid1 and Grid2.  When I click on an CommandButton in Grid1, I want Grid2 to disappear.  I can't get this to work.  The second grid will not disappear.

I am using AjaxManager to try and do this.  When I set Ajax to false, the postbacks update my page the way I want. 

0
Iana Tsolova
Telerik team
answered on 23 Jun 2008, 08:56 AM
Hi Lyn Mannato,

To update the second grid (make it visible/invisible) when action is performed by the first grid, you should add ajax setting where the first grid updated the second grid:

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, grid2); 

To update your grid1 when you perform action from the second grid, please add another ajax setting where the second grid updates the first:

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, grid1); 

To update both grid and panel when the command of the button in the panel is executed, you could add the following settings:

ajaxManager.AjaxSettings.AddAjaxSetting(aspPnel, aspPnel);  
ajaxManager.AjaxSettings.AddAjaxSetting(aspPnel, grid1);  
ajaxManager.AjaxSettings.AddAjaxSetting(aspPnel, grid2); 

Give this suggestions a try and let us know if any issues arise.

Additionally, you can find more information about RadAjaxManager here.

Kind regards,
Iana
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Lyn Mannato
Top achievements
Rank 1
answered on 25 Jun 2008, 01:05 PM
I got it to work.  I had to hook the buttons inside the aspPanel to the grids.
So, I have the following connections and it all seems to be working great!
Thanks!

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, grid1);

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, grid2);

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, aspPanel);

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, aspPanel);

ajaxManager.AjaxSettings.AddAjaxSetting(grid1, grid2);

ajaxManager.AjaxSettings.AddAjaxSetting(grid2, grid1);

ajaxManager.AjaxSettings.AddAjaxSetting(aspPanelBtn1, grid1);

ajaxManager.AjaxSettings.AddAjaxSetting(aspPanelBtn1, grid2);

ajaxManager.AjaxSettings.AddAjaxSetting(aspPanelBtn2, grid1);

ajaxManager.AjaxSettings.AddAjaxSetting(aspPanelBtn2, grid2);

Tags
General Discussions
Asked by
Lyn Mannato
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Lyn Mannato
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or