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

Radgrid rebind using JavaScript?

8 Answers 319 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 16 Apr 2009, 07:14 PM

We use many of your RadGrids in our application. There are times when we want to allow the user the opportunity to do an upload of substantial amounts of data that will ultimately be contained in one of these RadGrids.

 

To do this we use a RadWindow containing a fileUpload object. The user browses to the file containing the desired data, issues the upload command and our C# code then parses through the information and adds it to our data base.

 

What we would like to do is this – after the data base has been updated - directly after the RadWindow closes - we would like to issue, thru JavaScript if possible, a command(s) that would refresh the contents of our RadGrid. This would avoid a post back that we need to have now to refresh the main window.

 

Our RadWindow JavaScript logic contains the following line of code:

 

oWnd.add_close(OnClientClose);

 

 The OnClientClose method would be the ideal place any new code to refresh our RadGrid. We will be able to obtain the revised data by way of a Web Service.

 

Is this sort of thing possible?

 

Thanks   

8 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 21 Apr 2009, 01:12 PM
Hi Daniel,

Please, review the attached sample for comparison with your implementation. By analogy, you can make the RadWindow refresh the grid after the upload is done. You just need to add the code in the CloseAndRebind() client method (in EditFormCS.aspx) in your OnClientClose method.

I hope this helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan
Top achievements
Rank 2
answered on 21 Apr 2009, 07:46 PM
Thanks, this looks encouraging. I will take a crack at it in the next day or so and get back to you with the result.

There may be one more complexity here. I am wroking within a usercontrol and I recall seeing somewhere that one need implement an interface for doing this in usercontrols?

0
Dan
Top achievements
Rank 2
answered on 22 Apr 2009, 11:54 PM
Hi:

I found your exercise very helpful. However it did not quite accomplish what we need to do.

The button that issues the (JavaScript) call to open the Radwindow is on a user control (.ascx control). The RadGrid that we are hoping to refresh is also contained in the same user control.

I have modified the Code within the RadWindow in accordance with your code. In the main (.aspx) page, where the JavaScript also resides I have added the following method:

function OnWinClientClose(oWnd)

{

$find("<%= radAjaxManager1.ClientID %>").ajaxRequest("Rebind");

}


The RadAjaxManager is also in the .aspx page.

When the RadWIndow is dismissed it closes as we would expect and the aspx page does indeed post back just as we would want it to. The problem is that the user controls do not post back - and it is in them that we would see a change in the data.

I was reading elsewhere that we might require an interface for the user control in order to cause it to do the appropriate postback.

Can anyone advise me on how we can make this work fully?

Thank you for your help up till now. We could not have gotten this far without it and we are most appreciative.   
0
Dan
Top achievements
Rank 2
answered on 23 Apr 2009, 12:11 AM
I've found more on the Interface at this link:

http://www.telerik.com/help/aspnet/grid/grdmakepostbackajaxrequestfromusercontrolwebformmasterpage.html

So I added the code that was suggested there as follows:

public

partial class UserControls_ctlTeamMembers : ctlBOEBaseUserControl, IPostBackEventHandler  

{

 

 

 

 

protected void Page_Load(object sender, EventArgs e)

 {

 

 

     ......... 

}

 

 

 

public void RaisePostBackEvent(string eventArgument)

    TeamMembersGrid.Rebind();

}

 

 

 

In your document, mentioned above, you also seem to say that we would need to have the following line of JavaScript somewhere:

window["<%= TeamMembersGrid.ClientID %>"].AjaxRequest("<%= this.UniqueID %>", "MyArgument");

  

We don't know where this JavaScript should go (.aspx page, ascx page, which JavaScript method etc.) and if we need to substitute another value for "Myargument".

It appears that the PaisePostBack Event never fires and we still do not have a refreshing of the user control. But I imagine that this code gets us somewhat closer.

Do you have any suggestions?
0
Dan
Top achievements
Rank 2
answered on 23 Apr 2009, 10:46 PM
Another Telerik thread on asynchronous postbacks - of user controls - using Javascript and some of the techniques mentione d above can be found here:

http://www.telerik.com/support/kb/aspnet-ajax/grid/performing-postback-from-grid-client-events.aspx

I've not had a chance to look at this yet (and sadly, yes, I have no solution so far) but it does speak to user control issues - which is the stuff that's killing me.
0
Tsvetoslav
Telerik team
answered on 24 Apr 2009, 08:21 AM
Hi Daniel,

Please, find attached the sample reworked to your requirements and let us know if it helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dan
Top achievements
Rank 2
answered on 24 Apr 2009, 01:30 PM
Thanks so much.

I'll be looking at it right away and report back to you.
0
Dan
Top achievements
Rank 2
answered on 30 Apr 2009, 05:07 PM
Yes, we were able to get our application to work and, in fact, it now looks excellent. As time permits I will add a few more details which may be halpful for others. This is not the most obvious coding.

We did find that there was no need to use any interfaces in our user controls. In fact most of the changes were made in the .aspx object and almost nothing needed to change in the user control.

Thanks again to the people at Telerik for excellent customer support. 
Tags
Grid
Asked by
Dan
Top achievements
Rank 2
Answers by
Tsvetoslav
Telerik team
Dan
Top achievements
Rank 2
Share this question
or