Correct alternating item styles after hiding a row

4 posts, 1 answers
  1. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 21 Jan 2011 Link to this post

    When removing grid items after a delete for instance, I hide the grid item on the server side.

    GridDataItem gdi = (GridDataItem)((sender as ImageButton).NamingContainer);
    //hide the deleted record
    gdi.Visible = false;

    I have the grid in an update panel.
    Once the row is removed, the alternating styles is fudged if the user removes an alternate style between two like styles.

    Is there a way to get the grid to restyle the items after hiding one?
    Or am I forced to rebind? (I tried to just hide the row in an attempt to speed up performance since hiding one row seems like ti should be quicker than rebinding).

    Cheers
  2. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 02 Feb 2011 Link to this post

    Just looking for a means of restyling the grid items so that alternating styles don't follow one another after hiding a row.
    I'm currently doing everything on the server side using ajax.

    Maybe I just have to programatically grab the two rows, one before and one after, the item being deleted, check their styles and if they are the same, the style of the row one before the deleted one one... 
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Daniel
    Admin
    Daniel avatar
    4943 posts

    Posted 08 Feb 2011 Link to this post

    Hello Towps,

    Please try the following approach:
    protected override void OnPreRenderComplete(EventArgs e)
    {
        int itemorder = 0;
        foreach (GridItem item in RadGrid1.MasterTableView.Items)
        {
            if (item.Visible && item.Display)
            {
                if (itemorder % 2 == 0)
                    item.CssClass = "rgRow";
                else
                    item.CssClass = "rgAltRow";
                itemorder++;
            }
        }
     
        base.OnPreRenderComplete(e);
    }

    I hope this helps.

    Regards,
    Daniel
    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. towpse
    towpse avatar
    224 posts
    Member since:
    Mar 2008

    Posted 08 Feb 2011 Link to this post

    great, thanks. works nicely.
Back to Top