I'm trying to create a grid (MVC) that displays data from my model, with rows and cells with background color changing depending of boolean values.
1st try : I used ClientTemplate in my grid to add some class to my cell content.
hasErrorDateDebut and isActive are the booleans I used to determine if i need to color my cell in orange or green.
Issue : It only colors the div inside my td cell. Each td has padding that I can't remove (because each cell of the same line needs to have the same size I suppose), and so the paddings aren't colored. I also tried to set negative margin to counter this padding, but it only works to left and right, and not to top and bottom.
I now understand that I need to set my class/style to the td element, not the content. But I don't know how I can do so inside ClientTemplate. HtmlAttributes add style/class to the td element correctly, but I can't manage to do so with ClientTemplate.
Inside a document.ready, it added the desired style to the right td (tr for my green background). This worked perfectly, until I added an Edit command.
Issue : When I click on the edit button, and then validate or cancel my changes, my td and tr classes and styles are erased. I don't know why this happens and how I can prevent it ?
I tried to use a click function to the .k-grid-cancel to apply my styles again, but it doesn't work.
The log is displayed, but I think the grid and so the element with greenBack and orangeBack classes aren't load when the call is done. I tried to use onDataBound event but it isn't fired. Is there a way to apply my styles like this ?
3rd try : I tried to use RowTemplate, as it can allow me to set classes and styles directly to the tr and td I want. But I also want to use Edit command inline. Is there a way to declare it easily in a RowTemplate or only to define the columns I need in RowTemplate and not the whole grid ?
I hope it was clear enough. I tried many things, but everytime there is an issue I didn't manage to solve. If you can help me to make one of this solution works, let me know.