Radgrid rebind using JavaScript?

9 posts, 0 answers
  1. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 16 Apr 2009 Link to this post

    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   

  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 21 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 21 Apr 2009 Link to this post

    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?

  5. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 22 Apr 2009 Link to this post

    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.   
  6. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 22 Apr 2009 Link to this post

    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?
  7. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 23 Apr 2009 Link to this post

    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.
  8. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 24 Apr 2009 Link to this post

    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.
  9. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 24 Apr 2009 Link to this post

    Thanks so much.

    I'll be looking at it right away and report back to you.
  10. Dan
    Dan avatar
    25 posts
    Member since:
    May 2008

    Posted 30 Apr 2009 Link to this post

    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. 
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017