I'm looking for a way to change the background color for a cell through code, or maybe a better way to accomplish my goal.
I have a grid with multiple columns. Some of the columns aren't used depending on the value of other columns. So for example, I have a grid to define some fields that will be added to a table in a database. The first column is to select the data type, which will be Text or Numeric. I then have a column for Text Length, where the user will enter the max length for text in the field. If the user picks Numeric as the type, the Text Length cell, for that row, needs to be locked so the user can't enter anything.
To do this in a generic way, I use the OnCustomColumnDisplayText event in my grid and added a IsValueRequired(string fieldName) method in my model. If the IsValueRequired method returns false, I set the display text to string.empty. I also use the OnShowingEditor event to disable showing the editor if IsValueRequired returns false.
This works perfectly and I can show a blank value where the value isn't required and the cell is disabled so the user can't click into.
To make it more obvious to the user that the cell won't allow input, I would like to change the cell background color to grey.
Is it possible to do this trough code with the grid events? If not, is it possible to do this with a style? If it's a style, I'm not sure what I would use as the trigger for how the cell is displayed.
In some other places we we ShowAsNullText in OnCustomColumnDisplayText. Is there a way to change the cell style base on whether ShowAsNullText is being used in the cell?
Thanks for any help you can provide. I can throw together a quick example app if needed.