Update ListView inside RadWindow

3 posts, 0 answers
  1. Shawn
    Shawn avatar
    30 posts
    Member since:
    Jun 2014

    Posted 22 Feb Link to this post


    I have the following scenario: I have a RadGrid (parent) that has a nested RadGrid within it.  Inside the nested grid I have a GridTemplateColumn that contains a RadButton.

    <telerik:RadGrid ID="grdListEvents" runat="server" CssClass="RadGridEvents"
        <MasterTableView DataKeyNames="EventYear" Width="100%" HierarchyLoadMode="Client">
                <telerik:GridBoundColumn DataField="EventYear" ReadOnly="True" UniqueName="EventYear">
                    <ItemStyle CssClass="BOLD_Labels" />
                <telerik:RadGrid ID="grdNestedEvents" runat="server" Skin="Default" EnableEmbeddedSkins="true" CssClass="NestedGridEvents"
                    OnNeedDataSource="grdNestedEvents_NeedDataSource" OnItemCommand="grdNestedEvents_ItemCommand" OnItemDataBound="grdNestedEvents_ItemDataBound" OnItemCreated="grdNestedEvents_ItemCreated">
                    <MasterTableView EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true" TableLayout="Fixed" ShowGroupFooter="true" DataKeyNames="tEventID" ClientDataKeyNames="tEventID">
                             <telerik:GridTemplateColumn UniqueName="EditEvent" HeaderText="Event Details">
                                <HeaderStyle HorizontalAlign="Center" />
                                <ItemStyle HorizontalAlign="Center" />
                                    <telerik:RadButton runat="server" ID="lnkEditEvent"
                                        CssClass="rbClearButton rbHyperlinkButton">

    The OnClick client-event of the RadButton is set in the Nested grid's ItemCreated event.  This is done this way so that I can pass some needed parameters to the JavaScript function:

    if (e.Item is GridDataItem)
        GridDataItem item = (GridDataItem)e.Item;
        RadGrid grid = (RadGrid)sender;
        RadButton lnkEditEvent = (RadButton)item.FindControl("lnkEditEvent");
        int index = item.ItemIndex;
        int datakeyValue = Convert.ToInt32(item.GetDataKeyValue("tEventID"));
        string cssSelector = "RadWindow_EditEvent";
        string radWindow = "rdwEditEvent";
        string radWidth = "610";
        string radHeight = "610";
        lnkEditEvent.Attributes.Add("OnClick", "btnEdit_OnClientClick('" + lnkEditEvent.ClientID
            + "', '" + index + "', '" + grid.ClientID + "', '" + datakeyValue
            + "', '" + cssSelector + "', '" + radWindow + "', '" + radWidth + "', '" + radHeight + "')");

    The JavaScript function opens a RadWindow that contains a RadListView.  The RadListView is populated via a $.getJSON JQuery function that executes a WCF service that returns a JSON list that populates the RadListView.

    function btnEdit_OnClientClick(btnId, itemIndex, gridId, dataKeyValue, cssSelector, radWindow, radWidth, radHeight) {
        var url = "";
        //Open RadWindow
        var oManager = GetRadWindowManager();
        var oWnd = oManager.getWindowByName(radWindow);
        var width = getWidth('#' + cssSelector + '', radWidth);
        var height = getHeight('#' + cssSelector + '', radHeight);
        if (oWnd) {
            oWnd.setSize(width, height);
            oWnd.setSize(width, height);
        urlEventPhotos = '<%=strAppSettingEditEvents %>' + 'GetEventPhotos?EventID=' + dataKeyValue;
        strTrainingPhotos = '<%=(String.Format(strTrainingPhotosPath).ToString()).Replace("\\", "\\\\")%>';
        var lstEventPhotosEdit = $find('<%=lstEventPhotosEdit.ClientID%>');
        $.getJSON(urlEventPhotos, function (result) {
            //if (result) {
            $.each(result, function (a, item) {
                tEvent_photo_name = item.tEvent_photo_name;
                tEvent_photoPath = item.tEvent_photoPath;

    This all works fine.  When the user clicks on the RadButton the Radwindow opens and the RadListView is loaded with values obtained from the WCF service.

    Here's the markup for my RadWindow that resides inside a RadWindowManager:  

    <telerik:RadWindowManager ID="rwmEvents" runat="server"
            <telerik:RadWindow ID="rdwEditEvent" runat="server" Title="Edit Event" Modal="true" CenterIfModal="true"
                    <asp:UpdatePanel ID="pnlEditEvent" runat="server" UpdateMode="Conditional">
                            <div runat="server" id="divEditEvent">
                                        <div id="EditEventDiv" runat="server" class="EVENT_Div Shadow">
                                            <div class="DIV_One DIV_PhotoList">
                                                <asp:Label ID="lblEventPhotos" runat="server"
                                                    Text="Event Photos: "
                                                <telerik:RadListView ID="lstEventPhotosEdit" runat="server"
                                                        <div id="pnlPhotos"></div>
                                                        <DataBinding ItemPlaceHolderID="pnlPhotos">
                                                            <a href="#= strTrainingPhotos ##= tEvent_photoPath #" target="_blank" class="GeneralFont">#= tEvent_photo_name #</a> 
                                                            <EmptyDataTemplate><div class="GeneralFont">No photos have been uploaded.</div></EmptyDataTemplate>
                                                <div id="divFileUpload" runat="server" class="DIV_PhotoUpload">
                                                    <div style="padding-bottom: 5px;">
                                                        <asp:Label ID="lblFileUpload" runat="server" AssociatedControlID="rauPhotoUpload" Text="Select a Photo for Uploading:" CssClass="GeneralFont"></asp:Label>
                                                    <script type="text/javascript">
                                                        Telerik.Web.UI.RadAsyncUpload.Modules.Flash.isAvailable = function () { return false; }
                                                        Telerik.Web.UI.RadAsyncUpload.Modules.FileApi.isAvailable = function () { return false; }
                                                        //Telerik.Web.UI.RadAsyncUpload.Modules.IFrame.isAvailable = function () { return false; };
                                                        //Telerik.Web.UI.RadAsyncUpload.Modules.Silverlight.isAvailable = function () { return false; }
                                                    <telerik:RadAsyncUpload ID="rauPhotoUpload" runat="server" HideFileInput="true" UploadedFilesRendering="BelowFileInput" MaxFileInputsCount="1" AllowedFileExtensions="jpeg,jpg,gif,tif,tiff,png"
                                                        OnFileUploaded="rauPhotoUpload_FileUploaded" Skin="Default" EnableEmbeddedSkins="true" Localization-Select="Browse" OnClientValidationFailed="validationFailed">
                                                            <telerik:FileFilter Description="Images(jpeg,jpg,gif,tif,tiff,png)" Extensions="jpeg,jpg,gif,tif,tiff,png" />
                                                <div id="divFileUploadTitle" class="DIV_PhotoUploadTitle">
                                                    <div style="padding-bottom: 5px; padding-left: 5px;">
                                                        <asp:Label ID="lblPhotoTitle" runat="server" AssociatedControlID="" Text="Class Photo Title: " CssClass="GeneralFont"></asp:Label><br />
                                                        <telerik:RadTextBox ID="txtPhotoTitle" runat="server" Width="90%" Style="margin-top: 5px;"></telerik:RadTextBox>
                                        <div class="DIV_One_Buttons">
                                            <div class="DIV_One_Buttons_LFloat">
                                                <telerik:RadButton ID="btnSaveEditEvent" runat="server"
                                                    Text="Save Event" OnClick="btnSaveEditEvent_Click"
                                            <div class="DIV_One_Buttons_LFloat DIV_One_Buttons_LFloat_Padding">
                                                <telerik:RadButton ID="btnCloseEditEvent" runat="server" AutoPostBack="false"
                                                    OnClientClicked="function(sender, args){closeRadWindow(sender, args, 'rdwEditEvent');}"
                                                <asp:Label ID="lblEditEventMessage" runat="server" CssClass="LBL_AHU_Add_Message"></asp:Label>

    I have the following RadAjaxManagerProxy settings:

    <telerik:RadAjaxManagerProxy ID="rampAddEditFilters" runat="server">
            <telerik:AjaxSetting AjaxControlID="grdListEvents">
                    <telerik:AjaxUpdatedControl ControlID="grdListEvents" />
            <telerik:AjaxSetting AjaxControlID="pnlEditEvent">
                    <telerik:AjaxUpdatedControl ControlID="pnlEditEvent" />

    I also Ajaxify some of the controls during PageLoad event:

    protected void Page_Load(object sender, EventArgs e)
    private void Ajaxify()
            AjaxSetting ajaxSetting = new AjaxSetting();
            ajaxSetting.AjaxControlID = rauPhotoUpload.ID;
            ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl { ControlID = grdListEvents.ID, LoadingPanelID = alpAddEditEvents.ID });
            ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl { ControlID = lstEventPhotosEdit.ID, LoadingPanelID = null });
            ajaxSetting = new AjaxSetting();
            ajaxSetting.AjaxControlID = btnSaveEditEvent.ID;
            ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl { ControlID = grdListEvents.ID, LoadingPanelID = alpAddEditEvents.ID });
            ajaxSetting.UpdatedControls.Add(new AjaxUpdatedControl { ControlID = lstEventPhotosEdit.ID, LoadingPanelID = null });

    I use a RadAsyncUpload control to upload a single file to a location on the server and then I save the name of the file within our database.  That name is then displayed within the RadListView.  This is done when the user clicks on the RadButton "btnSaveEditEvent".  This mechanism also works.  The file is uploaded, and the file name is saved within the database, and then the RadWindow is closed.  

    The problem is that if the user click on the "Edit" button within the Nested RadGrid again to open the RadWindow (for example, to add another file later on) the RadWindow opens, but does not display the previously added file name within the RadListView.  The WCF service does not get invoked.  I have looked all over the Telerik forums and I searched the Internet for an answer, but I have been unsuccessful.   What am I doing wrong? I'd really appreciate any help.





  2. Shawn
    Shawn avatar
    30 posts
    Member since:
    Jun 2014

    Posted 23 Feb in reply to Shawn Link to this post

    I figured out the solution myself.  Just in case someone else is having this issue here's my solution.  The problem was ajax caching.  I had to set it to 'false' in order for $getJSON to get the new values.  Now, everything works like it should.

        cache: false

  3. DevCraft R3 2016 release webinar banner
  4. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 25 Feb Link to this post

    Hello Shawn,

    I'm glad that you have managed to fix the issue on your end. Thank you for sharing your solution with the community.

    Maria Ilieva
    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 Feedback Portal and vote to affect the priority of the items
Back to Top