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

Problem with ajax request

1 Answer 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jean
Top achievements
Rank 1
Jean asked on 25 May 2010, 04:57 PM
Hi ! I spent all this afternoon on a problem without findind a solution :(

I added an ASP.NET AJAX Q3 2009 Radgrid :
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AutoGenerateColumns="False" 
                    Skin="WebBlue" AllowSorting="True" AllowPaging="True" OnNeedDataSource="RadGrid1_NeedDataSource"  
                    OnItemCreated="RadGrid1_ItemCreated" 
                    EnableAJAX="True" OnItemCommand="RadGrid1_ItemCommand" OnItemEvent="RadGrid1_ItemEvent"
                        <SortingSettings SortedAscToolTip="Tri croissant" SortedDescToolTip="Tri d&#233;croissant" 
                            SortToolTip="Trier" /> 
                        <MasterTableView> 
                            <RowIndicatorColumn Visible="False"
                                <HeaderStyle Width="20px" /> 
                            </RowIndicatorColumn> 
                            <ExpandCollapseColumn Resizable="False" Visible="False"
                                <HeaderStyle Width="20px" /> 
                            </ExpandCollapseColumn> 
                            <Columns> 
                                <telerik:GridBoundColumn DataField="Cli" meta:resourcekey="CliColumnResource" UniqueName="Cli"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="ACId" meta:resourcekey="ACIdColumnResource" UniqueName="ACId"
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn DataField="ArchiveId" meta:resourcekey="ArchiveIdColumnResource" UniqueName="ArchiveId"
                                </telerik:GridBoundColumn> 
                            </Columns> 
                       </MasterTableView> 
                       <ClientSettings> 
                              <Selecting AllowRowSelect="True" /> 
                         </ClientSettings> 
                        <SelectedItemStyle BackColor="Blue" ForeColor="White" /> 
            </telerik:RadGrid> 

In code behind I added that :
RadGrid1.MasterTableView.ClientDataKeyNames = new string[] { "ArchiveId""ACId" }; 
 
            this.RadGrid1.ClientSettings.ClientEvents.OnRowSelected = "RowSelected"

in order to do something on row selected...

Here is the definition of RowSelected funtion :
<script type="text/javascript"
    function RowSelected(sender, eventArgs) { 
        var archiveId = eventArgs.getDataKeyValue("ArchiveId"); 
        var archiveClassId = eventArgs.getDataKeyValue("ACId"); 
        window["RadGrid1.ClientID"].AjaxRequest("RadGrid1.UniqueID""RadGrid1_RowSelected"); 
    } 
</script> 

And in code behind :
protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument) 
        { 
            base.RaisePostBackEvent(sourceControl, eventArgument); 
 
            if (eventArgument == null
                return
            if (eventArgument.Trim() == ""
                return
 
            string[] parts = eventArgument.Split(':'); 
            switch (parts[0]) 
            { 
                case "RadGrid1_RowSelected"
 
                    string[] subparts = parts[2].Split('¤'); 
 
                    TbxArchiveId.Text = subparts[1]; 
                    TbxCAId.Text = subparts[0]; 
 
                    break
            } 
        } 

When I debug with IE, it tells me that "window[...]" is null.

How can it be ?? :(

Can you help me please ?


1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 28 May 2010, 01:00 PM
Hello Jean,

To get the RadGrid on client side you need to use the $find() operator. Please check out the following online documentation article which explains how to get RadGrid client object:
http://www.telerik.com/help/aspnet-ajax/grdgettingradgridclientobject.html
Also to perform an ajax request from client side you need to get the RadAjaxManager and call its ajaxRequest() method. I believe that the following RadAjaxManager's HowTo section will be of help.

Sincerely yours,
Radoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Jean
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or