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

ListView Open RadWindow Code Behind Close Window Refresh Parent

1 Answer 145 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 2
Allan asked on 30 Oct 2010, 07:25 AM
I have a page with a RadListView Control:

    <telerik:RadListView ID="rlv_Responses" runat="server" DataKeyNames="IDTicketsResponses" 
        DataSourceID="sds_Responses" Skin="WebBlue" BorderColor="#5A7594" 
               BorderStyle="Solid" BorderWidth="1px" Width="400px">
    <AlternatingItemTemplate>
        <div class="rlvA">
            <table cellpadding="3" cellspacing="0" 
                style="border: thin solid #293852; padding: 10px; width: 100%">
                <tr>
                    <td style="padding: 5px">
                        <asp:Label ID="lbl_EnteredDate" runat="server" Text='<%# Eval("EnteredDate") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px">
                        <asp:Label ID="lbl_FullName" runat="server" style="font-weight: 700; color: #597791" Text='<%# Eval("FullName") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px">
                        <asp:Label ID="lbl_Response" runat="server" Text='<%# Eval("Response") %>' />
                        <asp:Label ID="lbl_TicketsResponses" runat="server" Text='<%# Eval("IDTicketsResponses") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px">
                        <asp:Button ID="SelectButton" runat="server" CommandName="Select" Text="Details" />
                        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                    </td>
                </tr>
            </table>
                                      
        </div>
    </AlternatingItemTemplate>
    <InsertItemTemplate>
    </InsertItemTemplate>
    <ItemTemplate>
        <div class="rlvI">
            <table cellpadding="3" cellspacing="0" 
                style="border: thin solid #293852; padding: 10px; width: 100%; background-color: #E6E6E6;">
                <tr>
                    <td style="padding: 5px;">
                        <asp:Label ID="lbl_EnteredDate0" runat="server" 
                            Text='<%# Eval("EnteredDate") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px;">
                        <asp:Label ID="lbl_FullName0" runat="server" 
                            style="font-weight: 700; color: #597791" Text='<%# Eval("FullName") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px;">
                        <asp:Label ID="lbl_Response0" runat="server" Text='<%# Eval("Response") %>' />
                        <asp:Label ID="lbl_TicketsResponses0" runat="server" Text='<%# Eval("IDTicketsResponses") %>' />
                    </td>
                </tr>
                <tr>
                    <td style="padding: 5px;">
                        <asp:Button ID="SelectButton" runat="server" CommandName="Select" Text="Details" /><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                             
                          
                    </td>
                </tr>
            </table>
        </div>
    </ItemTemplate>
    <EmptyDataTemplate>
        <div class="RadListView RadListView_Default">
            <div class="rlvEmpty">
                There are no items to be displayed.</div>
        </div>
    </EmptyDataTemplate>
    <LayoutTemplate>
        <div class="RadListView RadListView_Default">
            <div ID="itemPlaceholder" runat="server">
            </div>
        </div>
    </LayoutTemplate>
    <SelectedItemTemplate>
        <div class="rlvISel">
             <asp:Label ID="lbl_EnteredDate1" runat="server" 
                Text='<%# Eval("EnteredDate") %>' />
             <asp:Label ID="lbl_FullName1" runat="server" 
                Text='<%# Eval("FullName") %>' />
             <asp:Label ID="lbl_Response1" runat="server" 
                Text='<%# Eval("Response") %>' />
             <asp:Label ID="lbl_TicketsResponses1" runat="server"
                Text='<%# Eval("IDTicketsResponses") %>' />
        </div>
    </SelectedItemTemplate>
</telerik:RadListView>

Because I need to get the value of the DataKey from the list view I need to open a RadWindow during the ItemCommand Event in the code behind:

Protected Sub RadListView1_ItemCommand(ByVal sender As Object, ByVal e As RadListViewCommandEventArgs) Handles rlv_Responses.ItemCommand
       If e.CommandName = RadListView.SelectCommandName Then
           Dim item As RadListViewDataItem = TryCast(e.ListViewItem, RadListViewDataItem)
           Dim IDTicketsResponses As String = item.GetDataKeyValue("IDTicketsResponses").ToString()
           Session("IDTicketsResponses") = IDTicketsResponses
           Dim scriptstring As String = "radopen('helpdesk_tickets_respond_edit.aspx', 'EditResponse');"
           RadAjaxManager1.ResponseScripts.Add(String.Format("refreshGrid('{0}')", "Server Response!"))
           ScriptManager.RegisterStartupScript(Me, Me.[GetType](), "radopen", scriptstring, True)
       End If
   End Sub

Before adding the ListView control to the ASPX page, I used to open the window from the ASPX page using Java:

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript" language="javascript">
            function getQuerystring(key, default_) {
                if (default_ == null) default_ = "";
                key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
                var qs = regex.exec(window.location.href);
                if (qs == null)
                    return default_;
                else
                    return qs[1];
            }
            function AddResponse() {
                var param1 = getQuerystring('IDTicket');
                var param2 = getQuerystring('IDRequestor');
                var oWnd = radopen("helpdesk_tickets_respond.aspx?IDTicket=" + param1 + "&IDRequestor=" + param2, "UserListDialog");
                return false;
            }
            function refreshGrid(arg) {
                if (!arg) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
                }
            }
</script>
    </telerik:RadCodeBlock>

And close the RadWindow that was opened with this Java:

<script type="text/javascript">
    function Close(args) {
        GetRadWindow().BrowserWindow.refreshGrid(args);
        GetRadWindow().close();
    }
    function GetRadWindow() {
        var oWindow = null;
        if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog
        else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well)
        return oWindow;
    }
    function CancelEdit() {
        GetRadWindow().close();
    }
       </script>


When I used the ASPX page and java to open the window and then closed the window, the java did a great job of calling the RadAjaxManager and refreshing my ListView.

Now when I open the window from the VB code behind, the RadAjaxManager is no longer called when the pop up window is closed.

How can I ensure that the the RadAjaxManager fires when the pop up window closes even though the pop up is opened from the code behind?

I hope this was not TOO confusing. :)




1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 03 Nov 2010, 04:06 PM
Hello Allan,

If I understand correctly, you are firing the AJAX request in the OnClientClose event of the RadWindow. Could you please debug your javascript and see if the handler is called at all and if so, what is the value of args when you step through the method with a debugger? For some reason they may come as undefined or as false, thus skipping the line which fires an AJAX request.

Regards,
Tsvetina
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
ListView
Asked by
Allan
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Share this question
or