Issues with using fireCommand on multiple grids

6 posts, 1 answers
  1. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 10 May 2011 Link to this post

    I have two RadGrids that have selectable rows that popup RadWindows.  When the windows close, I refresh the RadGrids to apply changes made in the windows.  I do this by using fireCommand with a sort (at the time I created this kind of logic with another app, sort was the only command that seemed to work all the time to refresh).  It works fine if I just refresh one grid that way, but if I try to do two, neither refreshes.  Do I need to do something extra to get both grids to fire a command in the same javascript function?
  2. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 11 May 2011 Link to this post

    If it isn't possible, is there another way to refresh both?  I tried a few different methods that I could find, but they didn't seem to work.  The code I tried in my onClose function of the RadWindowManager on the parent page is below.

    var oRadGrid1 = $find("<%= RadGrid1.ClientID %>");
    if (oRadGrid1 != null) {
        var mtRadGrid1 = oRadGrid1.get_masterTableView();
        mtRadGrid1.fireCommand("Sort", "");
    }
    var oRadGrid2 = $find("<%= RadGrid2.ClientID %>");
    if (oRadGrid2 != null) {
        var mtRadGrid2 = oRadGrid2.get_masterTableView();
        mtRadGrid2.fireCommand("Sort", "");
    }
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mira
    Admin
    Mira avatar
    1124 posts

    Posted 13 May 2011 Link to this post

    Hello Mike,

    I assume the cause of the issue is that when the Sort command fires for the first grid, the whole page postbacks.
    In order to implement the desired functionality, I suggest that you refresh the both grids calling the RadAjaxManager.ajaxRequest method:
    JavaScript
    function WindowOnClose(args) {
        $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("SortGrids");
    }
    C#
    protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument == "SortGrids")
        {
            //sort the grids here
        }           
    }

    I hope this helps.

    Kind regards,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  5. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 13 May 2011 Link to this post

    Would I need to use some certain methods from the code behind to update the RadGrids?  I need the grid items to be refreshed.  Sorting the way I had been did that.  I tried DataBind(), Rebind(), and RaisePostBackEvent with a few different commands, but it doesn't seem to refresh the data in the grids.  I can see that the code behind is getting run when debugging, but it just doesn't update the grid..  What happens in the RadGrid could cause items to be added to, deleted from, or modified in the RadGrids on the parent page.
  6. Answer
    Mira
    Admin
    Mira avatar
    1124 posts

    Posted 18 May 2011 Link to this post

    Hello Mike,

    Rebinding the grids should be enough to refresh them. You can see how it is done in this demo.

    If the issue persists, please provide a little bit more details on your scenario and how the grid is data-bound. Sending us a sample runnable project will be highly appreciated.

    Greetings,
    Mira
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

  7. Mike Dennis
    Mike Dennis avatar
    51 posts
    Member since:
    Mar 2006

    Posted 19 May 2011 Link to this post

    That seems to work.  I think the issue I had with it before was that I didn't have the ajax manager listed in itself as a control that could cause others to be updated.  I guess I had thought that would have been implied..
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017