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

Enable AJAX for Grid and Edit Form

4 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 01 Mar 2011, 07:16 PM
I have a RadGrid with a Form Template for Inserting and Updating the data.  I would like to enable Ajax for the entire grid and for individual elements within the Grid.  I am using the AjaxManager and AjaxManagerProxy to attempt to accomplish this.  I have for example an AjaxManagerProxy within with FormTemplate which enables Ajax for a second RadGrid which sits within the EditForm and a second AajxManagerProxy inside a user control also within the edit form.  These all work as expected, but when I add the main RadGrid to the main AjaxManager all of the "sub" ajax updates cause the whole Grid to update rather than just the small section which was updating previously. 

To shed a but more light on what I am looking for, this is an example: 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="admin_Default2"

Title="Untitled Page" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>CSA - Compliance, Safety, Accountability</title>

</head>

<body runat="server" id="MyBody">

<a style="display: none;" href="#content">Skip to Content</a>

<form id="form1" runat="server">

<telerik:RadScriptManager ID="scriptManager" runat="server">

</telerik:RadScriptManager>

<telerik:RadAjaxManager runat="server" ID="ajaxManager">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="grid">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="grid" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManager>

<telerik:RadGrid runat="server" ID="grid" AutoGenerateColumns="true" AutoGenerateEditColumn="true"

OnNeedDataSource="getDocuments" Width="300">

<MasterTableView>

<EditFormSettings EditFormType="Template">

<FormTemplate>

<telerik:RadAjaxManagerProxy runat="server" ID="proxy">

<AjaxSettings>

<telerik:AjaxSetting AjaxControlID="btn">

<UpdatedControls>

<telerik:AjaxUpdatedControl ControlID="txt" />

<telerik:AjaxUpdatedControl ControlID="lbl" />

</UpdatedControls>

</telerik:AjaxSetting>

</AjaxSettings>

</telerik:RadAjaxManagerProxy>

<telerik:RadAsyncUpload runat="server" ID="fileUpload" />

<asp:TextBox runat="server" ID="txt" />

<asp:Button runat="server" ID="btn" OnClick="click" Text="Add" />

<asp:Label runat="server" ID="lbl" />

<asp:Button runat="server" CommandName='<%=RadGrid.UpdateCommandName%>' Text="Update" />

</FormTemplate>

</EditFormSettings>

</MasterTableView></telerik:RadGrid>

</form>

</body>

</html>



public partial class admin_Default2 : System.Web.UI.Page


{

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    protected void getDocuments(object sender, GridNeedDataSourceEventArgs e)

    {

        (sender as RadGrid).DataSource = new int[] { 2, 3, 4, 5, 6, 7 };

    }

    protected void click(object sender, EventArgs e)

    {

        ((sender as Button).NamingContainer.FindControl("lbl") as Label).Text +=

"<br/>" + ((sender as Button).NamingContainer.FindControl("txt") as TextBox).Text;

        ((sender as Button).NamingContainer.FindControl("txt") as TextBox).Text = "";

    }

}



The final result should be that clicking the add does not submit the rest of the edit panel, but clicking the other button does

4 Answers, 1 is accepted

Sort by
0
Andrew
Top achievements
Rank 1
answered on 02 Mar 2011, 09:33 PM
A bit better an example, what I am looking to achieve something like http://demos.telerik.com/aspnet-ajax/ajax/examples/manager/partialajaxification/defaultcs.aspx except that clicking the image button would not cause its grid to update and the secondary grid exists within the main one.
0
Pavlina
Telerik team
answered on 04 Mar 2011, 05:25 PM
Hello Andrew,

Please refer to the forum thread below for more information about the requested functionality:
http://www.telerik.com/community/forums/aspnet-ajax/ajax/ajax-in-editform-template.aspx

Regards,
Pavlina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Andrew
Top achievements
Rank 1
answered on 04 Mar 2011, 05:33 PM
SO the answer is basically that you can't  You either enable Ajax for certain components of the edit template with no ajax of the grid or you have a single set of ajax for everything.  The second solution would actually be somewhat acceptable if not for the way the AsyncFIleUpload responds which is essentially to clear its status any time any ajax request is fired.  As a second question departing a bit from the first.  Is it possible to preserve the state of th AsynFileUpload except when a certain button is pressed?  So if the user selects a file and we perform an ajax action to add a sub-item the file upload remains populated and is only cleared when they click the button intended to submit that item?
0
Pavlina
Telerik team
answered on 10 Mar 2011, 10:55 AM
Hello Andrew,

To achieve your goal try setting the RadAjaxManager settings dynamically inside the PreRender event instead of ItemCreated and let me know how it goes.

Regarding the problem with AsyncFileUpload - please let me know how the AsyncFIleUpload behaves on postback or ajax request when it is outside the grid.

Regards,
Pavlina
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Grid
Asked by
Andrew
Top achievements
Rank 1
Answers by
Andrew
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or