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

[Solved] Radgrid itemcommand not fired 1st time when radgrid is inside of a radwindow

6 Answers 336 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clayton
Top achievements
Rank 1
Clayton asked on 24 Feb 2011, 12:28 AM

Code-behind:
Imports Telerik.Web.UI
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
 
    Protected Sub RadGrid1_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
        Dim list As New ArrayList
 
        list.Add("blah")
        list.Add("blah 2")
        list.Add("this is an item")
        list.Add("another item")
 
        RadGrid1.DataSource = list
 
 
 
    End Sub
End Class

Markup:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <asp:Button runat="server" ID="showWindow" Text="click me" OnClientClick="radopen(null,'radWindow1'); return false;" />
    <telerik:RadWindowManager runat="server" ID="radWindowManager1" Modal="true" Style="z-index: 10000">
        <Windows>
            <telerik:RadWindow ID="radWindow1" runat="server" KeepInScreenBounds="true" Modal="true"
                Behaviors="Close" Width="700px" Height="400px" Title="test window">
                <ContentTemplate>
                    <div>
                        <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" ShowGroupPanel="True"
                            Width="100%" AllowSorting="True" OnNeedDataSource="RadGrid1_NeedDataSource">
                            <MasterTableView CommandItemDisplay="Top" />
                            <ClientSettings AllowDragToGroup="True">
                            </ClientSettings>
                        </telerik:RadGrid>
                </ContentTemplate>
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    </div>
    </form>
</body>
</html>


Click on the button to open the radWindow with radopen(), click on the 'add' commanditem on the grid. Notice that it takes two clicks to get the edit form to show. This holds true with any of the grid's itemcommands as long as it is in the radwindow. If you move the radgrid outside of the radwindow, itemcommand events fire normally.

You'll also notice that the 'add' commanditem on the grid causes a postback on first click as well, and if you look at __EVENTTARGET request param, you'll notice that it correctly shows the button that causes the event, however the event never fires until you click it a second time.











6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2011, 01:09 PM
Hello Clayton,

Try to add the RadGrid in another page use the following approach to open window .

Default.aspx: (page containing Radgrid)
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" ShowGroupPanel="True"
    Width="100%" AllowSorting="True" DataSourceID="SqlDataSource1">
    <MasterTableView CommandItemDisplay="Top" />
    <ClientSettings AllowDragToGroup="True">
    </ClientSettings>
</telerik:RadGrid>

ASPX:
<asp:Button runat="server" ID="showWindow" Text="click me" OnClientClick="radopen(); return false;" />
<telerik:RadWindowManager runat="server" ID="radWindowManager1" Modal="true" Style="z-index: 10000">
    <Windows>
         <telerik:RadWindow ID="radWindow1" runat="server" KeepInScreenBounds="true" Modal="true"
            Behaviors="Close" Width="700px" Height="400px" Title="test window" >
        </telerik:RadWindow>
    </Windows>
</telerik:RadWindowManager>

Java Script:
<script type="text/javascript">
    function radopen() {
        var oWnd = $find("<%=radWindow1.ClientID%>");
        oWnd.setUrl('Default.aspx');//page containing Radgrid
        oWnd.show();
     }
   
</script>

Thanks,
Princy.
0
Clayton
Top achievements
Rank 1
answered on 24 Feb 2011, 04:30 PM
I've considered this approach, but it does not really work in my scenario. 

I have a more-complex radgrid with a button column on my actual web application, and when a button in a grid row is clicked, the event issues a response.redirect to reload the page with certain session parameters changed. My understanding is that if I issue a response.redirect from a radgrid that is in a frame, the frame will redirect but the parent page will not (I need it to)

Is there no other way to get events to fire correctly with a radgrid in a radwindow?
0
Accepted
Mira
Telerik team
answered on 28 Feb 2011, 02:10 PM
Hello Clayton,

To use the RadAjaxManager control in integration with a RadWindow as demonstrated in this demo you should use a separate RadWindow control and not to wrap it in a RadWindowManager.

Please try this and let me know whether it works for you.

Regards,
Mira
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
Clayton
Top achievements
Rank 1
answered on 28 Feb 2011, 06:23 PM
This sounds promising, however you'll see in my code above that the window must be opened client-side by a button. Using radopen() doesn't seem to work properly when the radwindow is not in a radwindowmanager. Do you have any suggestions?

EDIT: Found a way here. Solution seems to work perfectly, events from the grid are fired on first try, and radwindow is displayed on client button click! Thanks for the help!
0
Prasanna
Top achievements
Rank 1
answered on 17 May 2013, 01:22 PM
Hai,
               Am using Radgrid inside Radwindow. When I am clicking inside Radgrid for the first time, the "itemcommand" is not working.
               I reviewed previous conversations and found that it can be resolved by seperating both Radgrid and Radwindow in two different aspx pages, which is not possible to my case, since i am using both Radgrid and Radwindow inside an userControl.
             Can anyone help me out ???
              Thanks in advance.
0
Eyup
Telerik team
answered on 22 May 2013, 07:42 AM
Hello Prasanna,

I have prepared a sample RadGrid web site to test the described behavior. On my side the ItemCommand event is fired correctly. Can you please run the attached application and verify that it works as expected on your end, too?

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Clayton
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Clayton
Top achievements
Rank 1
Mira
Telerik team
Prasanna
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or