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

Restore Original Row Color

6 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 30 Oct 2013, 09:03 PM
I have a grid with conditional row coloring to indicate status.  I am also using the drag and drop functionality.  When I select rows, the row color is changed to indicate selected.  When I unselect rows, the original row colors are not restored.  Instead, the rows are set to white.  How can I preserve the original row colors?  Thank you.

6 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Oct 2013, 04:25 AM
Hi Richard,

Please try setting the following style for your RadGrid. The code works fine at my end to highlight the selected row and the rows retain the original color on deselect.

CSS:
<style type="text/css">
.RadGrid_SkinName .rgSelectedRow td
{
    background-color: Green;
    border-bottom-color: Green !important;
}
</style>

Thanks,
Princy
0
Richard
Top achievements
Rank 1
answered on 31 Oct 2013, 02:26 PM
I am setting the row colors in ItemDataBound based on data conditions:

e.Item.BackColor = Color.Gray;

When I select rows and unselect them the original row color is not preserved.  Instead the row color is set to white.  The style you sent affected the selected row color but it did not restore the original row color.
0
Princy
Top achievements
Rank 2
answered on 01 Nov 2013, 07:42 AM
Hi Richard,

Below is a sample code that i tried and i was able to retain the row color. Please provide your code snippet if this doesn't help to identify the issue.

ASPX:
<ClientSettings Selecting-AllowRowSelect="true">
</ClientSettings>

C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem data = (GridDataItem)e.Item;
        string id = data.GetDataKeyValue("ID").ToString();
        if (id == "Some Conditon")
        {
            e.Item.BackColor = Color.Gray;
        }
    }
}

Thanks,
Princy
0
Richard
Top achievements
Rank 1
answered on 06 Nov 2013, 02:38 PM
I am using Internet Explorer 10.  It is still not working.  The options I currently have set are as follows:

<style type="text/css">

    .rgSelectedRow td {

    background-color: Yellow !important;

    border-bottom-color: Yellow !important;

}

</style>


<
SelectedItemStyle BackColor="Yellow" CssClass="rgSelectedRow" />

<ClientSettings AllowRowsDragDrop="true">

     <Scrolling AllowScroll="true" UseStaticHeaders="true" />

     <Selecting AllowRowSelect="True" EnableDragToSelectRows="false" />

     <ClientEvents OnScroll="SetScrollPosition" />

</ClientSettings>

Please advise.  Thank you.

0
Princy
Top achievements
Rank 2
answered on 07 Nov 2013, 03:53 AM
Hi Richard,

I see that you have set back-color using CSS, as well as the SelectedItemStyle. Please remove SelectedItemStyle tag and use only the CSS for setting back-color as follows. Set the Skin you are using instead of the SkinName.

CSS:
<style type="text/css">
    .RadGrid_SkinName .rgSelectedRow td
    {
        background-color: Yellow !important;
        border-bottom-color: Yellow !important;
    }
</style>

Please try and let me know if any concern.
Thanks,
Princy
0
Richard
Top achievements
Rank 1
answered on 18 Nov 2013, 06:44 PM
That solved the issue!  Thank you so much!
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Richard
Top achievements
Rank 1
Share this question
or