Radwindow disappearing when button inside the window is pressed:

1 Answer 123 Views
ComboBox Grid Window
Carlos
Top achievements
Rank 1
Iron
Carlos asked on 17 Oct 2022, 09:46 PM
Helllo, I would like the radwindow to stay on top of the form when selecting the "Select" button inside the combobox. The Select button does some server side work. The Reprocess button it will also do server side work. The only time the radwindow will close is when pressing the Close button.   For the 'Select' Button I could replace the code with javascript but I'm not sure how to go about it.  Below is my sample code 
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Linq.aspx.vb" Inherits="CreatePAth.Linq" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function stopPostBack() {
                return true;
            }


            function openAssayErrors() {
                var wnd = $find("<%=winAssayErrors.ClientID%>");
                wnd.show();
                return false;
            }
            function closeAssayErrors() {
                var wnd = $find("<%=winAssayErrors.ClientID%>");
                wnd.close();
                return false;
            }

            function RefreshParentPage() {
                document.location.reload();
            }
            function stopPostback() {
                return true;
            }
        </script>
    </telerik:RadCodeBlock>

</head>
<body>
    <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">

                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btnCloseWinx">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="btnSelectComment">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="btnSelectComment" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="bAssayErrors">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="bAssayErrors" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
            </telerik:RadAjaxManager>
            <telerik:RadGrid ID="RadGrid1" AllowAutomaticUpdates="True"
                RenderMode="Lightweight" runat="server" AllowSorting="True" ShowStatusBar="true" AutoGenerateColumns="False"
                EnableHeaderContextMenu="True"
                Height="220"
                ViewStateMode="Enabled"
                EnableViewState="true">
                <ClientSettings>
                    <Scrolling AllowScroll="true" FrozenColumnsCount="14" SaveScrollPosition="true" UseStaticHeaders="true" />
                </ClientSettings>
                <MasterTableView HeaderStyle-ForeColor="White" EnableColumnsViewState="false" AllowAutomaticUpdates="true" AllowSorting="True" EnableLinqGrouping="False" GroupsDefaultExpanded="False" Width="100%" TableLayout="fixed" DataKeyNames="Item, ErrorSamples">
                    <Columns>
                        <telerik:GridBoundColumn DataField="Item" FilterControlAltText="Item" HeaderText="Item" UniqueName="Item" AllowFiltering="false">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn HeaderStyle-Width="150px" HeaderText="Error Samples" DataField="ErrorSamples" UniqueName="ErrorSamples">
                            <ItemTemplate>
                                <telerik:RadButton ID="bAssayErrors" ButtonType="LinkButton" Width="80px" AutoPostBack="true" OnClientClicked="openAssayErrors" CommandName="SelectAssayErrors" runat="server" Text='<%# Eval("ErrorSamples") %>'></telerik:RadButton>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>

            <div>
                <asp:Label ID="lblmessage" runat="server" Text=""></asp:Label>
            </div>
            <telerik:RadWindow ID="winAssayErrors" runat="server" Modal="true" VisibleTitlebar="True" VisibleStatusbar="false"
                ReloadOnShow="true"
                ShowContentDuringLoad="false"
                Width="950px" Height="500px"
                Title="List by Assay" Style="z-index: 100001;">
                <ContentTemplate>
                    <div>
                        <table>
                            <tr>
                                <td>
                                    <asp:Label ID="lblAssayName" runat="server" Text=""></asp:Label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <telerik:RadGrid ID="rgAssays" AllowAutomaticUpdates="True"
                                        RenderMode="Lightweight" Skin="Default" runat="server" AllowSorting="True" ShowStatusBar="true" AutoGenerateColumns="False" OnItemDataBound="rgAssays_ItemDataBound" OnItemCommand="rgAssays_ItemCommand"
                                        EnableHeaderContextMenu="True"
                                        Height="220px"
                                        Width="900px"
                                        ViewStateMode="Enabled"
                                        EnableViewState="true">
                                        <ClientSettings>
                                            <Scrolling AllowScroll="true" FrozenColumnsCount="14" SaveScrollPosition="true" UseStaticHeaders="true" />
                                        </ClientSettings>
                                        <MasterTableView HeaderStyle-BackColor="" EnableColumnsViewState="false" AllowAutomaticUpdates="true"
                                            AllowSorting="True" EnableLinqGrouping="False" GroupsDefaultExpanded="False" Width="100%" TableLayout="fixed" ShowFooter="true"
                                            DataKeyNames="AssayName,  NoSamples, OKSamples">
                                            <Columns>
                                                <telerik:GridBoundColumn DataField="AssayName" FilterControlAltText="AssayID" HeaderText="AssayName" UniqueName="AssayName" AllowFiltering="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="NoSamples" FilterControlAltText="NoSamples" Display="true" HeaderText="# Samples" UniqueName="NoSamples" AllowFiltering="false">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="OKSamples" FilterControlAltText="OKSamples" HeaderText="Ok Samples" UniqueName="OKSamples" ReadOnly="true">
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="Comments" FilterControlAltText="Comments" HeaderText="Comments" UniqueName="Comments" ReadOnly="true">
                                                </telerik:GridBoundColumn>

                                                <telerik:GridTemplateColumn HeaderStyle-Width="150px" HeaderText="Reprocess" DataField="Reprocess" UniqueName="Reprocess">
                                                    <ItemTemplate>
                                                        <telerik:RadCheckBox ID="chkReprocess" AutoPostBack="false" Width="80px" runat="server"></telerik:RadCheckBox>
                                                    </ItemTemplate>
                                                </telerik:GridTemplateColumn>
                                                <telerik:GridTemplateColumn HeaderStyle-Width="250px" HeaderText="RPNote" DataField="RPNote" UniqueName="RPNote">
                                                    <ItemTemplate>
                                                        <telerik:RadComboBox runat="server" ID="cbRPNote" Height="300px" Width="100px "
                                                            DropDownWidth="500"
                                                            ViewStateMode="Enabled"
                                                            MarkFirstMatch="true"
                                                            HighlightTemplatedItems="True"
                                                            EmptyMessage="select"
                                                            CheckBoxes="false"
                                                            AllowCustomText="false"
                                                            Style="z-index: 200001;">
                                                            <HeaderTemplate>
                                                                <table style="width: 500px; text-align: left">
                                                                    <tr>
                                                                        <td style="width: 50px;">ID</td>
                                                                        <td style="width: 200px;">Spec. Comments</td>
                                                                        <td style="width: 200px;">User Comments</td>
                                                                        <td style="width: 80px;"></td>
                                                                    </tr>
                                                                </table>
                                                            </HeaderTemplate>
                                                            <ItemTemplate>
                                                                <table style="width: 550px; text-align: left; float: right;">
                                                                    <tr>
                                                                        <td style="width: 50px;">
                                                                            <asp:Label ID="Rejection_ID" runat="server" Text='<%# Eval("Rejection_ID") %>'></asp:Label>
                                                                        </td>
                                                                        <td style="width: 200px;">
                                                                            <asp:Label ID="Txt_Description" runat="server" Text='<%# Eval("Txt_Description") %>'></asp:Label>
                                                                        </td>
                                                                        <td style="width: 200px;">
                                                                            <asp:TextBox ID="txt_RPNote" runat="server" Text=""></asp:TextBox>
                                                                        </td>
                                                                        <td style="width: 80px;">
                                                                            <telerik:RadButton ID="btnSelectComment" OnClick="btnSelectComment_Click" runat="server" Text="Select"></telerik:RadButton>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </ItemTemplate>
                                                        </telerik:RadComboBox>
                                                    </ItemTemplate>
                                                    <FooterTemplate>
                                                        <asp:Label ID="Label1" runat="server" Text=" Do Server stuff and return.... "></asp:Label>
                                                        <telerik:RadButton ID="imRP" runat="server" Text="Reprocess" OnClick="imRP_Click" CommandName="Reprocess"></telerik:RadButton>
                                                        <telerik:RadButton ID="btnCloseWinx" runat="server" Text="Close"></telerik:RadButton>

                                                    </FooterTemplate>
                                                </telerik:GridTemplateColumn>
                                            </Columns>
                                        </MasterTableView>
                                    </telerik:RadGrid>
                                </td>
                            </tr>
                        </table>
                    </div>
                </ContentTemplate>
            </telerik:RadWindow>

        </div>
    </form>
</body>
</html>



Imports Telerik.Web.UI

Public Class Linq
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            Dim AssysGroup = New List(Of Assays) _
        From {New Assays With {.AssayName = "C6", .NoSamples = "12", .OKSamples = "1", .Comments = "OK", .Reprocess = True},
                New Assays With {.AssayName = "Crtert", .NoSamples = "5", .OKSamples = "2", .Comments = "OK", .Reprocess = False},
                New Assays With {.AssayName = "POWEB", .NoSamples = "2", .OKSamples = "1", .Comments = "OK", .Reprocess = False},
                New Assays With {.AssayName = "POWELISA", .NoSamples = "4", .OKSamples = "0", .Comments = "fds", .Reprocess = False},
                New Assays With {.AssayName = "CTT", .NoSamples = "3", .OKSamples = "0", .Comments = "", .Reprocess = False},
                New Assays With {.AssayName = "POWEA", .NoSamples = "5", .OKSamples = "1", .Comments = "", .Reprocess = False}}
            rgAssays.DataSource = AssysGroup
            rgAssays.DataBind()

            Dim MainGrid = New List(Of sItems) _
             From {New sItems With {.Item = "AAA", .ErrorSamples = 10},
                New sItems With {.Item = "BBB", .ErrorSamples = 12},
                New sItems With {.Item = "CCC", .ErrorSamples = 0},
                New sItems With {.Item = "DDD", .ErrorSamples = 0}}
            RadGrid1.DataSource = MainGrid
            RadGrid1.DataBind()
        End If

    End Sub

    Private Class Assays
        Property AssayID As String
        Property AssayName As String
        Property NoSamples As String
        Property OKSamples As String
        Property Comments As String
        Property Reprocess As Boolean


    End Class


    Private Class sItems
        Property Item As String
        Property ErrorSamples As String

    End Class

    Protected Sub rgAssays_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs)
        If TypeOf e.Item Is GridDataItem Then
            Dim gridItem As GridDataItem = TryCast(e.Item, GridDataItem)
            Dim dt As DataTable = New DataTable()
            Dim combo As RadComboBox
            combo = gridItem.FindControl("cbRPNote")
            dt.Columns.Add("Rejection_ID", GetType(Integer))
            dt.Columns.Add("Txt_Description", GetType(String))
            dt.Columns.Add("txt_RPNote", GetType(String))
            dt.Rows.Add(1, "Not enough solution", "")
            dt.Rows.Add(2, "Positve Result", "")
            dt.Rows.Add(3, "Damage Specimen", "")
            dt.Rows.Add(4, "Equipment failute", "")
            dt.Rows.Add(5, "User mistake", "")
            combo.DataTextField = "Txt_Description"
            combo.DataValueField = "Rejection_ID"
            combo.DataSource = dt
            combo.DataBind()
        End If
    End Sub

    Protected Sub rgRPNote_SelectedIndexChanged(sender As Object, e As RadComboBoxSelectedIndexChangedEventArgs)
        Dim val As String = e.Text
    End Sub

    Protected Sub btnSelectComment_Click(sender As Object, e As EventArgs)
        Dim button As RadButton = CType(sender, RadButton)
        Dim s As String = CType(button.NamingContainer.FindControl("Txt_Description"), Label).Text
        Dim s1 As String = CType(button.NamingContainer.FindControl("txt_RPNote"), TextBox).Text
        CType(button.NamingContainer.Parent, RadComboBox).Text = s1
    End Sub


    Protected Sub imRP_Click(sender As Object, e As EventArgs)
        For Each item As GridDataItem In rgAssays.Items
            Dim chkRP As RadCheckBox = CType(item.FindControl("chkReprocess"), RadCheckBox)
            If chkRP.Checked = False Then
                lblmessage.Text = "Please Enter an RPNote for Items to be reprocess"
                lblmessage.Focus()
                Exit Sub
            End If
            If CType(item.FindControl("cbRPNote"), RadComboBox).Text.Length > 0 Then
                Dim s As String = "yea doing long background work"
            End If
        Next
    End Sub


End Class

Carlos
Top achievements
Rank 1
Iron
commented on 25 Oct 2022, 12:55 PM

Thank you for your response. The links you sent were very helpful.

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 20 Oct 2022, 11:27 AM

Hi Carlos,

Thank you for the provided code!

The structure of nested controls is indeed a complex one for Ajaxifying.

I would recommend you check out our Understanding AJAX Controls article to get a better overview of how the RadAjaxManager works compared to the native asp:UpdatePanel.

In such a hierarchy of controls (Window->Grid->ComboBox->Button) you should be extra careful when defining the AjaxSettings so that nesting Ajax is avoided - AjaxManager Settings Are Not Working When Controls Are Wrapped in an AjaxPanel and Added to the Settings.

As the current case seems to be about Ajaxifying the Button itself (the one in the ItemTemplate of the ComboBox), you may need to add some AjaxSettings programmatically - Add AjaxSettings to the AajaxManager Programmatically.

One possible approach you can test is to use the Load event of the RadButton to define the needed AjaxSettings for the AjaxManager. For instance:

<telerik:RadButton ID="btnSelectComment" OnClick="btnSelectComment_Click" runat="server" Text="Select" OnLoad="btnSelectComment_Load"></telerik:RadButton>

VB

Protected Sub btnSelectComment_Load(sender As Object, e As EventArgs)
    Dim button = TryCast(sender, RadButton)
    'let the button update itself via Ajax
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(button, button, Nothing)
    'allow updating the Grid via ajax request
    RadAjaxManager1.AjaxSettings.AddAjaxSetting(button, rgAssays, Nothing)
End Sub

I hope this will help.

Kind regards,
Doncho
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ComboBox Grid Window
Asked by
Carlos
Top achievements
Rank 1
Iron
Answers by
Doncho
Telerik team
Share this question
or