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

Open radWindow in a toolBar in a grid

4 Answers 102 Views
Window
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 14 Jul 2011, 04:04 PM
Hi,

I'm currently trying to open a radWindow on a parent page from a click on a button on a toolBar inside a grid (I get the idea from this demo), but it doesn't work well. The only thing I can do is to open the new window behind the current window and the modal/title attribute don't work at all (but the size it correct). If I try to open the window from a standard button, it works just fine. Is it anyone who know why this doesn't work ?

Thank you
David

Here is my code :

Default.aspx :

<!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">
        function yo(sender, e) {
            radopen("test.aspx", null);
        }
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
     
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server"
            EnableShadow="true" RestrictionZoneID="RestrictionZone"
            ShowContentDuringLoad="False">
        <Windows>
            <telerik:RadWindow ID="win1" runat="server" VisibleStatusbar="false" Behaviors="Close,Move" Width="750px" Height="400px" Modal="true" Title="I'm not working" />
        </Windows>
    </telerik:RadWindowManager>
     
    <div>
        <telerik:RadButton ID="yo" runat="server" Text="yo" AutoPostBack="false" OnClientClicked="yo">
        </telerik:RadButton>
    </div>
    </form>
</body>
</html>


test.aspx:

<!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>
 
    <script type="text/javascript">
        function here(sender, e) {
            var win = GetRadWindow().BrowserWindow;
            win.radopen(null, "win1"); // Open a window that is define in the radWindowManager of the parentPage
        }
 
        // Donne la référence d'une fenêtre radWindow
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow)
                oWindow = window.radWindow;
            else if (window.frameElement.radWindow)
                oWindow = window.frameElement.radWindow;
            return oWindow;
        }
    </script>
 
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadButton ID="but1" runat="server" AutoPostBack="false" Text="Click here Dude!"
            OnClientClicked="here">
        </telerik:RadButton>
 
        <telerik:RadScriptManager runat="server"></telerik:RadScriptManager>
 
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_needDS">
            <MasterTableView AutoGenerateColumns="false" Name="test" CommandItemDisplay="Top"
                    DataKeyNames="Id">
                <CommandItemTemplate>
                    <telerik:RadToolBar ID="RadToolBarGrid" runat="server" OnClientButtonClicking="here">
                        <Items>
                            <telerik:RadToolBarButton Text="Add new" ImageUrl="~/Images/Add.png">
                            </telerik:RadToolBarButton>
                        </Items>
                    </telerik:RadToolBar>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridBoundColumn DataField="Id" HeaderText="Id" UniqueName="Id">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Style" HeaderText="Style" UniqueName="Style">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Rating" HeaderText="Rating" UniqueName="Rating">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>   
    </div>
    </form>
</body>
</html>


test.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace RadControlsWebApp5
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void RadGrid1_needDS(object sender, EventArgs e)
        {
            List<movie> movies = new List<movie>();
 
            movies.Add(new movie(1, "King Kong", "Action", "4/5"));
            movies.Add(new movie(2, "The Black Knight", "Action", "4.5/5"));
            movies.Add(new movie(3, "Harry Potter and the deadly hallow", "Fantasy", "4/5"));
            movies.Add(new movie(4, "Inception", "Sc-fiction", "5/5"));
            movies.Add(new movie(5, "Transformer : The revenge of the fallen", "Action, Sc-Fiction", "3/5"));
 
            RadGrid1.DataSource = movies;
        }
    }
 
    public class movie
    {
        public movie(int id, string title, string style, string rating)
        {
            Id = id;
            Title = title;
            Style = style;
            Rating = rating;
        }
 
        public int Id { get; private set; }
        public string Title { get; private set; }
        public string Style { get; private set; }
        public string Rating { get; private set; }
    }
}


EDIT :

Sorry, I notice that the title just work fine in this example. In fact, I realize that if I set a title in the <title></title> in the head of a aspx page, this title come over the title of the window setting.  

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Jul 2011, 08:28 AM
Hello David,
Try the the following approach to achieve your scenario.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
 {
  if (e.Item is GridCommandItem)
    {
        GridCommandItem item = (GridCommandItem)e.Item;
        RadToolBar tool = (RadToolBar)item.FindControl("RadToolBarGrid");
        RadToolBarButton button = (RadToolBarButton)tool.FindItemByText("Add new");
      button.Attributes.Add("onclick", "openWindow();");
    }
 }

Javascript:
function openWindow()
{
     window.radopen(null, 'RadWindow1');
 }

Thanks,
Shinu.
0
David
Top achievements
Rank 1
answered on 15 Jul 2011, 02:29 PM
Hi Shinu,

Thank you for your answer, but it doesn't work. Maybe I didn't explain correctly my problem. I have a window (default.aspx) that open a new window (test.aspx). In the text.aspx window, I want to open a another window at the same level of the default.aspx window, but I want the new window to appears over the test.aspx window (like in this demo). Your answer seem to suggest me to open the new window directly in the test.aspx window, which mean that the window will be stuck inside the test.aspx window, what I don't want. So, I try your example, but I modify the js function to open it in the default.aspx window and it doesn't work. In fact, it act the same way than before. So, do you have any others solution ?

Thank you,
David
0
Accepted
Marin Bratanov
Telerik team
answered on 19 Jul 2011, 11:01 AM
Hello David,

Please examine this online demo (and more specifically the openWin2() JavaScript function in Dialog1.aspx) and this help article for more information on opening a RadWindow from within another RadWindow.


Regards,
Marin
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
David
Top achievements
Rank 1
answered on 19 Jul 2011, 02:35 PM
Hi Marin,

Thank you for your answer, but it wasn't of any help. I already check this demo, like I said in my last post, and the help article only suggest me to do something that I already done in the code I put on my first post. Anyway, I change my mind and I think I will use a button outside of the grid. 

David

-- Edit

I found the solution. I had to put a setTimeout like in this demo. Took me time to figure out, 'cause I didn't believe that the setTimeout would make it work. 
Tags
Window
Asked by
David
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or