Open RadWindow on ajax RadGrid, serverside

2 posts, 0 answers
  1. Matteo Beretta
    Matteo Beretta avatar
    21 posts
    Member since:
    Apr 2010

    Posted 13 Aug 2010 Link to this post

    Hi, i have a radgrid with, a link column, and on itemcommand i want to open a radwindow by server side, i try this:
    but the window can't show
    thanks

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                        <AjaxSettings>
                            <telerik:AjaxSetting AjaxControlID="rgrAnalisi">
                                <UpdatedControls>
                                    <telerik:AjaxUpdatedControl ControlID="rgrAnalisi" 
                                        LoadingPanelID="RadAjaxLoadingPanel1" />
                                </UpdatedControls>
                            </telerik:AjaxSetting>
                        </AjaxSettings>
                    </telerik:RadAjaxManager>
      
                    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" 
                        EnableViewState="False">
                    </telerik:RadWindowManager>
      
                    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
                    </telerik:RadAjaxLoadingPanel>
      
      
                      <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
                            <script type="text/javascript">
                            <!--
      
                                function gridCommand(sender, args) {
                                    if (args.get_commandName() == "Rapportino" || args.get_commandName() == "DownloadAttachment") {
                                        var manager = $find('<%= RadAjaxManager.GetCurrent(Page).ClientID %>');
                                        manager.set_enableAJAX(false);
      
                                        setTimeout(function () {
                                            manager.set_enableAJAX(true);
                                        }, 0);
                                    }
                                }
      
                                function conditionalPostback(sender, eventArgs) {
                                    var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                                    var eventArgument = eventArgs.get_eventArgument();
      
                                    if (eventArgument.indexOf("Update") > -1 || eventArgument.indexOf("PerformInsert") > -1) {
                                        if (upload && upload.getFileInputs()[0].value != "") {
                                            eventArgs.set_enableAjax(false);
                                        }
                                    }
                                }
                                -->
                            </script>
                    </telerik:RadCodeBlock>
      
      
                    <telerik:RadGrid runat="server" ID="rgrAnalisi" Skin="Vista"
                            AllowPaging="True" AllowSorting="True" GridLines="None" PageSize="12"
                            style="margin-top: 100px; margin-left:27px;"  Width="900px" 
                            ShowGroupPanel="True"
                        ondetailtabledatabind="rgrAnalisi_DetailTableDataBind" 
                        oncolumncreated="rgrAnalisi_ColumnCreated" 
                        onitemdatabound="rgrAnalisi_ItemDataBound" 
                        onitemcommand="rgrAnalisi_ItemCommand">
      
                            <GroupingSettings CaseSensitive="false" />
                            <PagerStyle Mode="NumericPages"/>
                            <ClientSettings>
                            <Selecting  AllowRowSelect="true"/>
                            <ClientEvents OnCommand="gridCommand" />
                            </ClientSettings>
      
                            <MasterTableView ShowHeadersWhenNoRecords="true" >
                                 <DetailTables>
                                    <telerik:GridTableView Name="Customer" Width="100%">
                                        <Columns>
                                                <telerik:GridBoundColumn UniqueName="colCustomer" HeaderText="Cliente" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="colComm" HeaderText="Commessa" Visible="false">
                                                </telerik:GridBoundColumn>
                                        </Columns>
                                        <DetailTables>
                                            <telerik:GridTableView Name="Commesse" Width="100%">
                                                <Columns>
                                                <telerik:GridBoundColumn UniqueName="colCustomer" HeaderText="Cliente" Visible="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn UniqueName="colComm" HeaderText="Commessa" Visible="false">
                                                </telerik:GridBoundColumn>
                                                </Columns>
                                                    <DetailTables>
                                                        <telerik:GridTableView Name="Rapportini" Width="100%">
                                                        <Columns>
                                                            <telerik:GridBoundColumn UniqueName="colCustomer" HeaderText="Cliente" Visible="false">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridBoundColumn UniqueName="colComm" HeaderText="Commessa" Visible="false">
                                                            </telerik:GridBoundColumn>
                                                            <telerik:GridTemplateColumn UniqueName="colView" ItemStyle-HorizontalAlign="Center" AllowFiltering="false">
                                                                <ItemTemplate>
                                                                    <asp:Image runat="server" ID="linkView" ImageUrl="~/images/Zoom.png">
                                                                    </asp:Image>
                                                                    <telerik:RadToolTip runat="server" Width="300" Height="300" RenderInPageRoot="true" ShowEvent="OnMouseOver"
                                                                            HideEvent="ManualClose" HideDelay="2" ID="Tooltip" Position="TopRight" Animation="Resize"
                                                                            RelativeTo="Element" >
                                                                    </telerik:RadToolTip>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                            <telerik:GridTemplateColumn UniqueName="colView" ItemStyle-HorizontalAlign="Center" AllowFiltering="false">
                                                                <ItemTemplate>
                                                                    <asp:LinkButton runat="server" ID="linkRappo" Text="Rapportino" CommandName="Rapportino">
                                                                    </asp:LinkButton>
                                                                </ItemTemplate>
                                                            </telerik:GridTemplateColumn>
                                                        </Columns>
                                                        </telerik:GridTableView>
                                                    </DetailTables>
                                            </telerik:GridTableView>
                                        </DetailTables>
                                    </telerik:GridTableView>
                            </DetailTables>                  
                            <Columns>
                                <telerik:GridBoundColumn UniqueName="colMese" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="colEseguite" Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn UniqueName="colAddebitare" Visible="false">
                                </telerik:GridBoundColumn>
                            </Columns>
                            </MasterTableView>
                    </telerik:RadGrid>
    protected void rgrAnalisi_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Rapportino")
            {
                GridDataItem item = e.Item as GridDataItem;
                short Year = short.Parse(txtYear.Text); ;
                int Number = int.Parse(item["NumeroRappo"].Text);
                Session.Add("RappoYear", Year);
                Session.Add("RappoNumber", Number);
                Session.Add("RappoProvenience", "Rapportini");
                RadWindowManager manager = new RadWindowManager();
                RadWindow newwindow = new RadWindow();
                newwindow.ID = "RadWindow2";
                newwindow.NavigateUrl = "Rapportino.aspx";
                newwindow.VisibleTitlebar = true;
                newwindow.Behaviors = WindowBehaviors.Close;
                newwindow.VisibleOnPageLoad = true;
                manager.Windows.Add(newwindow);  
            }
        }
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Aug 2010 Link to this post

    Hello,


    Thanks for giving the code. From your code I can see that you are creating new RadWindowManager and the control is not added on page. You need to add the control to container control (Panel, Form, PlaceHolder  etc) to work.

    C#:
          . . .
        newwindow.Behaviors = WindowBehaviors.Close;
        newwindow.VisibleOnPageLoad = true;
        manager.Windows.Add(newwindow);
        this.form1.Controls.Add(manager); // Add the dynamically created control on page
    }



    Otherwise, you can add the new window to the RadWindowManager which you already have in your page.
    C#:
           . . .
        newwindow.Behaviors = WindowBehaviors.Close;
        newwindow.VisibleOnPageLoad = true;
        RadWindowManager1.Windows.Add(newwindow);
    }


    Hope this help.

    Sincerely,
    Shinu.
Back to Top