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

[Solved] changing the background of a row on server side/client side

1 Answer 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 17 Feb 2010, 10:42 PM
How would I change the background of a specific row on a server side and a client side. I would like to do it in two ways, one with an image and another way with standard color code.
Thank you very much.

1 Answer, 1 is accepted

Sort by
0
Erwin Floresca
Top achievements
Rank 1
answered on 17 Feb 2010, 11:25 PM
Hi,

you can do it on the server side using ItemDataBound event. You can set the background image by specifying cssclass property of e.item.

VB.NET
Protected Sub rgS_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgS.ItemDataBound 
Select Case e.Item.ItemType 
      Case GridItemType.AlternatingItem, GridItemType.Item  
          e.Item.BackColor = Drawing.Color.AliceBlue 
          e.Item.CssClass = "CustomRow" 'this customrow css class will reference 'background image. 
End Sub 


On the client side you can use OnRowDataBound event. you will specify the event in the clientsettings in radgrid
<CODE><telerik:RadGrid ID="RadGrid1" EnableViewState="false" runat="server"
            AllowPaging="true" AllowSorting="True" AllowFilteringByColumn="true" GridLines="None">
            <ItemStyle Wrap="false" />
            <MasterTableView AllowMultiColumnSorting="true" TableLayout="Fixed">
                <Columns>
                   
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnCommand="RadGrid1_Command" OnRowDataBound="RadGrid1_RowDataBound" />
            </ClientSettings>
        </telerik:RadGrid>

</CODE>

function RadGrid1_RowDataBound(sender, args)
        {
            // conditional formatting
            args.get_item().get_cell("TitleOfCourtesy").style.fontWeight = (args.get_dataItem()["TitleOfCourtesy"] == "Dr.")? "bold" : "normal";           
        }
Tags
Grid
Asked by
Martin
Top achievements
Rank 1
Answers by
Erwin Floresca
Top achievements
Rank 1
Share this question
or