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

Need help with RadGrid AJAX

4 Answers 39 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 02 Sep 2011, 01:39 PM
Hi,

Here's what I want to do:

- Have 2 RadGrids, let's call them left and right
- When I select an item from the left grid (by clicking a link, which I created using a GridButtonColumn ButtonType="LinkButton"), it adds it to the right grid (I did this by storing the right grid item collection in session)

That's about it.
Currently, my code kinda works, except:

- It reloads the whole page, no AJAX
- After page reload, the new item is not visible in the right grid yet, it requires another reload (which is logical: first post back to enter the ItemCommand event handler method, at which point it's too late to fill in the right grid as it has already been databound, so the second reload is needed so the right grid retrieves the new item from the session)

What's the best way to address both issues?
Load the right grid in JS, or something? Maybe even the left one too, as the actual scenario is a bit more complex than what I detailed above (the left grid items depend on stuff you selected in a menu).

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Sep 2011, 01:58 PM
Hello,

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="LeftGrid">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RightGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
leftgrid_itemCommand()
{
   if(e.CommandName == "YourCommandName")
  {
      // your code for add data in DB or session
...................................
   // If you used advance databinding
    RightGrid.Rebind()
 .......................
// If you not used advance databinding  
   RightGrid.DataSource = "";
   RightGrid.DataBind();
.....................................
   }
}

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Thomas
Top achievements
Rank 1
answered on 02 Sep 2011, 02:42 PM
Hi,

Thanks for the quick reply! It works.

I was confused about the empty RadAjaxLoadingPanel, and thought I had to put one or both grids in it, but I see I need to leave it empty.

Thanks a lot.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Sep 2011, 07:23 PM
Hello,

Correct, You have to put grid outside the RadAjaxLoadingpanel.

Some facts about RadAjaxloadingPanel.
  1. By default, when IsSticky is false, the RadAjaxLoadingPanel will appear over the updated control. If you set IsSticky to true, the panel will appear where you have set it in the WebForm.
  2. by default, it display one loading image in the center.if you want to modify then
  3.     <telerik:RadAjaxLoadingPanel ID="LoadingPanel1" runat="server" Width="256px" Height="64px">
        <asp:Label ID="Label2" runat="server" ForeColor="Red">Loading... </asp:Label>
        <asp:Image ID="Image1" runat="server" Width="224px" Height="48px" ImageUrl="Loading.gif">
        </asp:Image></telerik:RadAjaxLoadingPanel>

you can also get more facts from here

Thanks,
Jayesh Goyani
0
Thomas
Top achievements
Rank 1
answered on 05 Sep 2011, 12:23 PM
Hello,

In case it may help other people, one thing to note: you need to include a ScriptManager on your page or control, or the AJAX won't work.
Thanks again for your help, Jayesh.
Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Thomas
Top achievements
Rank 1
Share this question
or