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

Alternate style on a Row

5 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
SKmatt
Top achievements
Rank 1
SKmatt asked on 14 Mar 2008, 11:24 AM
Hi,

I'm looking to have an alternate color on row, like css possibilities in webform.

I'm sure I've seing it in style builder but i don't find it anymore.
Thanks for your help.

5 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 17 Mar 2008, 05:06 PM
Hello SKmatt,

You can achieve alternate row style programmatically or by setting an appropriate theme.

Should you prefer to do it by code, subscribe to the RowFormatting event and then in the event handler change the color of the row:

void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)  
{  
    if (e.RowElement.IsOdd)  
    {  
        if (!e.RowElement.IsCurrent)  
        {  
            e.RowElement.BackColor = Color.Beige;  
        }  
        else 
        {  
            e.RowElement.BackColor = Color.LightBlue;  
        }  
    }  

If you want to implement it in your theme, you should add the IsOdd state to the GridRowElement and adjust the other state tabs correspondingly.

If you need additional assistance, do not hesitate to contact me.

Best wishes,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
SKmatt
Top achievements
Rank 1
answered on 18 Mar 2008, 10:02 AM
Thanks.

I prefer to use the style builder, but when i use the isOdd state my highlight on the cell make my state go to initial after.
 
What do i forgot to have a non initial return state after my mouse was over the row.

have a good day.
0
Nikolay
Telerik team
answered on 21 Mar 2008, 10:05 AM
Hi SKmatt,

As I have mentioned, you need to adjust the rest of the state tabs of the GridRowElement, so to define the logic by which the states will turn into each other. Below are listed the sample steps for producing the right set of tabs, which will avoid returning to InitialState after MouseOver:
  1. Select GridRowElement in the Control Structure tree.
  2. Add a new state tab. Assing IsOdd and (!IsCurrent or !IsSelected) state. Uncheck Auto un-apply checkbox.
  3. Edit the IsMouseOver state tab by checking the Auto un-apply checkbox and unchecking the Animate checkbox.
  4. Delete IsMouseOver and (!IsSelected and !IsCurrent) tab.
  5. Set appropriate colors to the different tabs so to achieve the effect you are looking for.

Please notice that the above steps were applied to a pre-built theme. I have attached the result theme for your reference,

If you need additional assistance, do not hesitate to contact me.

Sincerely yours,

Nikolay
the Telerik team


Instantly find answers to your questions at the new Telerik Support Center
0
SKmatt
Top achievements
Rank 1
answered on 21 Mar 2008, 10:24 AM
Thank's, it work fine.
You make great job and I support you on aspnetpro.com :o)
0
Nikolay
Telerik team
answered on 24 Mar 2008, 05:55 PM
Hello SKmatt,

I am glad to hear that your issue has been resolved. If you need additional assistance, do not hesitate to contact us.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
SKmatt
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
SKmatt
Top achievements
Rank 1
Share this question
or