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

Correct alternating item styles after hiding a row

3 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
towpse
Top achievements
Rank 2
towpse asked on 21 Jan 2011, 06:51 PM
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

3 Answers, 1 is accepted

Sort by
0
towpse
Top achievements
Rank 2
answered on 02 Feb 2011, 06:10 PM
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... 
0
Accepted
Daniel
Telerik team
answered on 08 Feb 2011, 04:22 PM
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.
0
towpse
Top achievements
Rank 2
answered on 08 Feb 2011, 09:59 PM
great, thanks. works nicely.
Tags
Grid
Asked by
towpse
Top achievements
Rank 2
Answers by
towpse
Top achievements
Rank 2
Daniel
Telerik team
Share this question
or