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

RadGrid Data Refresh on RadWindow Save / Close

5 Answers 138 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mk
Top achievements
Rank 1
mk asked on 12 Apr 2010, 02:10 AM
I know that there have been a few posts around this so I will try to keep this short. I have tried practically every solution without luck. Here is my situation.

I have a RadGrid control on Default.aspx page.  This RadGrid has an Edit Link which invokes RadWindow which opens
the CreateEdit.aspx page.  After making changes, when I hit Save, I want to RadWindow to close AND RadGrid in the Default.aspx ( Parent ) page to refresh.  I am able to save the changes but the RadGrid does not get updated.  When I refresh the Default.aspx page, I see the updated changes.

Can someone guide me step by step as to what needs to be done to implement this functionality.  ASP.net coding in c# or vb.net is easy, but when it comes to javascript, I get super confused.

Thanks,
Mk



5 Answers, 1 is accepted

Sort by
0
mk
Top achievements
Rank 1
answered on 12 Apr 2010, 07:04 PM
Bump ... Anyone ?
0
Charles
Top achievements
Rank 2
answered on 12 Apr 2010, 08:25 PM
I've had the same situation. I searched the forum and did find some answers which I've been able to implement with some success. Here is an example of one that I was able to get working.

It basically uses a combination of a button, hidden within a no-display div. The button has a normal server-side event handler. This is the code that will refresh the grid. The idea is, when you close the RadWindow, you need to call some JavaScript code that locates the button and executes the click() event. That will run the server-side code to refresh the grid.

First, the mark-up:
<div style="display:none;">  
    <asp:Button ID="btnProfilesRefresh" runat="server" OnClick="ProfilesRefresh" /> 
</div>  

 The RadWindowManager markup that links to a client-side event that fires when the window closes:
<telerik:RadWindowManager ID="rwm" runat="server">  
    <Windows> 
        <telerik:RadWindow ID="EditProfilePopup" runat="server" ReloadOnShow="true" Modal="true"   
        VisibleStatusbar="false" EnableEmbeddedSkins="false" Skin="MSWindowSkin" OnClientClose="OnPopupClosed">  
        </telerik:RadWindow> 
    </Windows> 
</telerik:RadWindowManager> 

The JavaScript that fires when the window closes, finds the button (I also am dealing with a hidden field that I store some data in), and fires the click event server-side:
function OnPopupClosed(sender, args)  
{  
    var details = $get("<%=details.ClientID %>");  
    if (args.get_argument() != null)  
    {  
        details.value = args.get_argument();  
        // refresh display here  
        var btn = $get("<%=btnProfilesRefresh.ClientID %>");  
        btn.click();  
    }  

The server-side code would be whatever you need to do to refresh your grid's data. Here is what I do:
protected void ProfilesRefresh(object sender, EventArgs e)  
{  
    DisplayMessage("");  
    StringBuilder sb = null;  
    UserModel um = new UserController().GetUser(Page.User);  
    ProfileController pc = new ProfileController();  
    List<ProfileModel> pList = null;  
    try 
    {  
        pList = pc.ListProfiles(um.Id).ToList();  
    }  
    catch (Exception ex)  
    {  
        pList = new List<ProfileModel>();  
        msgDetails.Value = ex.Message;  
        sb = new StringBuilder();  
        sb.Append("<span id=\"lblAlert\" ")  
            .Append(  
            "style=\"font-family:Verdana; font-size:10px; font-weight:bold; color:#CC0000; background-color:#FFFCE8;\"")  
            .Append(">Problem retrieving profiles.").Append("</span>&nbsp;&nbsp;&nbsp;");  
        sb.Append("<a href=\"javascript:DisplayDetails();\" style=\"font-family:Verdana; font-size:10px; font-weight:bold;\">View Details</a>");  
        SetMessage(sb.ToString());  
    }  
 
    rgrdProfiles.DataSource = pList;  
    rgrdProfiles.Rebind();  

I hope that helps.
0
Jayavidya
Top achievements
Rank 1
answered on 10 Jan 2011, 02:45 PM
Hello Team,
 I have the same problem. But I cannot use the solution provided above as I have usercontrol which has the radgrid. And if I give the button click event called in javascript, it refers to the page containing the usercontrol (with the grid). Please provide me a solution asap.

Thanks,
JJ
0
Lisa
Top achievements
Rank 1
answered on 18 Nov 2013, 04:39 PM
Charles - It's been a long time since you posted, but just in case you're still out there.....THANK YOU SO MUCH! I too read all the posts and nothing worked and they were very difficult to understand. Your clear and simple posting made excellent sense to me and most importantly, worked for me. Thanks again.
0
Charles
Top achievements
Rank 2
answered on 18 Nov 2013, 05:24 PM
Lisa

Still around, although not that active on these forums at present.

I'm glad that the posting helped you out. Good luck.
Tags
Grid
Asked by
mk
Top achievements
Rank 1
Answers by
mk
Top achievements
Rank 1
Charles
Top achievements
Rank 2
Jayavidya
Top achievements
Rank 1
Lisa
Top achievements
Rank 1
Share this question
or