Setting a cell background in a client template

1 Answer 71 Views
Grid
AP
Top achievements
Rank 1
Iron
Iron
Veteran
AP asked on 22 Dec 2022, 02:48 PM

I have a grid which needs to have some conditional formatting on certain cells.  I have achieved this via the model, and a client template, which does work.

The style is passed as a field to the client template.
actl3.Bound(o => o.QualifiedNight_Actual).Title("Registered Nurse/Nursing Associate").HeaderHtmlAttributes(new { style = "text-align: center; justify-content: center;overflow: visible !important;white-space: normal !important;" }).ClientTemplate("<div class=#=QualifiedNightColour#>#=QualifiedNight_ActualText#</div>");

The style is

.stWarning {
    background-color: red;
    width: 100%;
    
}

However, there is still padding around the div which remains a different colour. How can I make the entire cell have the desired background colour? I did try applying negative margins to the style, but this only seemed to work for the left side of the cell.

As just using the client template works well apart from this, I'm really not keen on having to add more JavaScript code for this (as there are nine fields in the grid that need this applying).

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 27 Dec 2022, 12:20 PM

Hello,

 

Thank you for getting back to us.

You were close - you can achieve this requirement using only CSS with this trick:
https://dojo.telerik.com/ULanIFIb/21

But don't tell anyone :)

 

Regards,
Eyup
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

AP
Top achievements
Rank 1
Iron
Iron
Veteran
commented on 29 Dec 2022, 10:09 AM

Eyup,  Thanks - I've got this working now.
Tags
Grid
Asked by
AP
Top achievements
Rank 1
Iron
Iron
Veteran
Answers by
Eyup
Telerik team
Share this question
or