Different color for Cells in Flex - apache-flex

I have datagrid in which some cells (not entire columns) are editable and others are not(all is predefined).what we want to achieve is that to differentiate editable and uneditable cells applying differnet colors.
How to achive this?
Thanks in advance.

Use an itemRenderer and set style colors inside the itemRenderer. Depending on your complexity you may consider conditionally setting the style of the itemRenderer based on the data.

Related

React DataGrid Single Row Customization

Working with a Material UI react data grid for the first time and I need to apply a custom background color to only the first 3 rows, each being a different color. The custom coloring of these rows is static, nothing that's supposed to happen after an event takes place. Is there any way to point to only one row and apply a background color to it from my scss file?
On a slightly related note, how do I extend column separators so they fill the data grid?
Thank you in advance!
use nth-child(1){}
for style the number 1 child.

Dynamic css for one cell in DataTable - PrimeNG

I'm using databale from PrineNG in my angular+typescript project.
I have datatable with some editable cells.
I want to change cell background color in some cases.
I know I can use 'bodyStyleClass'. But I need to take some css class based on whole row (I need to compare two values).
It means background color should be dynamically changed by my method.
How I can do this?

Flex: Row based rendering in Datagrid

I need to have custom rendering of each row in my datagrid. It is column based by default. Is there some way to achieve this?
If any one has tried this before or has any idea in this regard, then please share.
Thanks in advance.
Ashine.
If all you want is different colors, there is an alternatingItemColors style in DataGrid's base class ListBase. You can set an array of colors.
The colors to use for the backgrounds of the items in the list. The value is an array of two or more colors. The backgrounds of the list items alternate among the colors in the array.
For DataGrid controls, all items in a row have the same background color, and each row's background color is determined from the array of colors.
What kind of customization are you looking for?

Flex - How to find Datagrid Cell Object

I have datagrid in my page and I want to change particular cell background color. I don't want to use itemrenderer. Is there any alternate ?
Here is an example of changing the selection color: Flex Examples
If you want to do more than that, I'm afraid you will have to use an itemRenderer.
You could subclass DataGrid and override the protected drawRowBackground() method or possibly drawColumnBackground(). These are intended to draw the background for an entire row or column but you may be able to get it to draw a special color only for the cell(s) you want.

Formatting AdvancedDataGrid Cells

I have a quick question about rendering the advanceddatagrid cells.
I need to programatically color the cell of the datagrid based on the conditions. Lets say, the stock quotes. If there is an increase from the previous day, I need to have the cell colored in GREEN and in RED, when there is a decrease.
Now, the important part here is, I need to do these things dynamically, which means, when the user enables the comparison/conditions, then the cells are colored. And when the user disables the comparison, then it again goes back to its default behavior.
I know I have to use renderers. But not sure, how to use it for the cells and that too dynamically. Can anyone please explain how to go for it?
Thanks
Item renderers are components used to define the appearance of a component's "items" or subcomponents. In the case of the ADG, the "items" are the individual cells. You can create a completely custom class to function as the renderer (given it implements certain required interfaces) or, in most cases, you extend an existing component. Since the default renderer for ADG cells doesn't support background colors, you have to create or extend a component that does and use that as the renderer. That is the basic premise that these tutorials, linked to in the following question, work from:
Setting background color for datagrid row in Adobe Flex
After creating an itemRenderer that supports a background color, you have two options as to where you can define your "conditions"; inside of the itemRenderer or using the ADG's styleFunction (additionally requiring that your itemRenderer defines a "background" style).
In your case, you could include both today's and yesterday's stock price values in the data sent to each cell and compare the two to determine the color used to draw the background. Again, more on that in the tutorial links provided above. In either the itemRenderer or the styleFunction, you would compare properties on the itemRenderer's/styleFunction's data object (corresponding to the row you're looking at), e.g.:
if(data.today > data.yesterday)
{
// set color or return style
}
else ...
To "toggle" custom cell colors, switch between your custom renderer and the default (colorless) renderer. In other words, set the itemRenderer property to your custom itemRenderer class when you need display the colors and set it to "null" when you want the "default behavior".

Resources