Performance Issues with Ajaxified Radgrid

2 posts, 0 answers
  1. Smith
    Smith avatar
    9 posts
    Member since:
    Sep 2011

    Posted 20 Oct 2011 Link to this post

    Hello,

    I have a Ajaxified Grid that populates a sub grid using the OnRowSelected ClientEvent. It also opens a modal edit control with Javascript. This MasterRadGrid is rather large and takes a couple of seconds to load. The OnRowSelected even calls the rowSelected function.

    function rowSelected(senders, args) {
        var ajaxManager = $find('<%= RadAjaxManager1.ClientID %>');
        var selectedIndex = args.get_itemIndexHierarchical();
        ajaxManager.ajaxRequestWithTarget('<%= MasterRadGrid.UniqueID %>', selectedIndex);
    }

    Which calls the RaisePostBackEvent...

    protected override void RaisePostBackEvent(IPostBackEventHandler sourceControl, string eventArgument)
    {
        try
        {
            viewstateColumnSequence = 0;
     
            base.RaisePostBackEvent(sourceControl, eventArgument);
            var grid = sourceControl as RadGrid;
     
            if (grid != null)
            {
                try
                {
                    var gridItem = grid.Items[eventArgument];
                    gridItem.FireCommandEvent(RadGrid.SelectCommandName, String.Empty);
                }
                catch { }
            }
        }
        catch (Exception ex)
        {
        }
    }

    Which fires the CommandEvent for select...

    protected void MasterRadGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
    {
        //Needed to reset the column created column names
        viewstateColumnSequence = 0;
     
        try
        {
            if (e.Item != null && e.Item.ItemIndex >= 0)
            {
                if (e.CommandName == "Select")
                {
                    string tempCiIdHidden = ChildTabControl.myCiIdHidden.Value;
                    HiddenField myCiIdHidden = (HiddenField)e.Item.FindControl("CiIdHidden");
                    if (tempCiIdHidden != myCiIdHidden.Value)
                    {
                        LoadChildGrid(myCiIdHidden.Value);
                    }
     
                    //Needed to persist the custom column template changes
                    MasterRadGrid.Rebind();
                }
            }
        }
        catch (Exception ex)
        {
        }
    }

    My issue is that every time the row is selected, it raises a postback event that reloads the MasterRadGrid, whether the data needs refreshed or not. I'm stumped on how to raise the postback event to load the child grid but prevent the MasterRadGrid from reloading. Any ideas on what I'm missing or a direction you can point me in?

    Thanks for taking a look.

    Smith

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 26 Oct 2011 Link to this post

    Hi Smith,

    Note that it is not needed to rebind the MasterRadGrid in ItemCommand event. Actually the rebind will not ensure that the changes are persisted. The select command by default does not call rebind so it is not needed in your case also. Please remove the MasterRadGrid.Rebind() form the ItemCommand event and let me know how it goes.


    Best wishes,
    Maria Ilieva
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top