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

Update Controls Outside RADGrid

3 Answers 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ben
Top achievements
Rank 1
Ben asked on 20 Apr 2012, 12:21 PM
When I click on a button inside the RADGrid, how do I also update controls that exist outside of the grid?
I've tried the following so far:

1) RADAjaxManager.ResponseScripts.Add(String.Format("window['{0}'].AjaxRequest();", Me.RadAjaxPanel_PackageDetails.ClientID)
2) I also tried RADAjaxManager.AjaxSettings.AddAjaxSetting(Me.gridMain, Me.RadAjaxPanel_PackageDetails)
3) I also tried wrapping my grid in it's own RadAjaxPanel and used it's ResponseScripts.Add() method

None of these options seemed to have any effect what-so-ever. What link am I missing to get this to work?

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 Apr 2012, 01:46 PM
Hello,

Please check below code snippet.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
    AllowPaging="True" OnPreRender="RadGrid1_PreRender" AutoGenerateColumns="false">
    <PagerStyle AlwaysVisible="true" />
    <MasterTableView>
        <Columns>
          .............
          ...........
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    DateTime dt = new DateTime();
 
    dynamic data = new[] {
            new { ID = 1, Name ="Name1", customdate=dt,NO = 11.00},
            new { ID = 2, Name = "Name2", customdate=dt,NO = 11.00},
            new { ID = 3, Name = "Name3", customdate=dt,NO = 11.00},
            new { ID = 4, Name = "Name4", customdate=dt.AddYears(2011),NO = 11.44},
            new { ID = 5, Name = "Name5", customdate=dt,NO = 10.4}
        };
 
    RadGrid1.DataSource = data;
}
 
 
protected void Page_Load(object sender, EventArgs e)
{
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(RadGrid1, Label1, null);
}
protected void RadGrid1_PreRender(object sender, EventArgs e)
{
 
    Label1.Text = DateTime.Now.ToString();
}


Thanks,
Jayesh Goyani
0
Ben
Top achievements
Rank 1
answered on 20 Apr 2012, 03:00 PM
Jayesh,

Thank you for your response. Problem is, theServerSide method that runs when the button on the RADGrid is clicked, makes changes to several controls outside the grid, and it also "shows / hides" controls based on certain data. I was hoping to "wrap" all my controls within some sort of panel that I can then update the panel so all my changes get pushed to the client. Is that possible?
0
Ben
Top achievements
Rank 1
answered on 20 Apr 2012, 08:13 PM
I figured it out.

Originally I was using code I found on the Telerik site:
   RADAjaxManager.ResponseScripts.Add(String.Format("window['{0}'].AjaxRequest();", Me.RadAjaxPanel_PackageDetails.ClientID)

Apparently that doesn't format the command correctly. I later found a similar peice of code, that fed the argument differently:
   RADAjaxManager.ResponseScripts.Add(Me.RADAjaxPanelMain.GetAjaxEventReference(""))

Apparentlythe RADAjaxPanelMain.GetAjaxEventReference() method builds the argument needed for the ResponseScripts.Add() properly as apposed to the original method I found. Now I can manually call any UpdatePanel's "refresh" ability from any other UpdatePanel.

Thanks for the input!

Tags
Grid
Asked by
Ben
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Ben
Top achievements
Rank 1
Share this question
or