The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
I have inherited the GridDropDownMonthCalendarCellRenderer and have been using it to successfully read the values of cells to which the calling model is assigned.
What I cannot seem to do is change the TextColor of the cell. I know the renderer is wired in properly to CellModel etc...
I have boiled the problem down to it's essence as shown below: (if this is placed in a custom renderer then the cell color remains black).
I have partialy solved this problem by overriding the OnPrepareViewStyleInfo scince I would like the custom formatting changes to be made from within the model rather than subscribing to events (could get messy). The problem that I have now is that any changes I make to formatting do not persist in subsequent calls to OnPrepareViewStyleInfo. The solution to this seems to be to apply the formatting every time OnPrepareViewStyleInfo is called which seems expensive (I call a validation function of a custom property object on the cell model each time OnPrepareViewStyleInfo is called).
If I try to put in an updateFormatting flag that is set to true each time OnSaveChanges() is called, the changes are not persisted for calls to OnPrepareViewStyleInfo where the flag is false.
Pseudo c# shown below: public override void OnPrepareViewStyleInfo(GridPrepareViewStyleInfoEventArgs e) { if (updateFormatting) { //get the model object MyCustomClass myCustomClass = (MyCustomClass)((MySyncStyleProperties)e.Style).Model; if (myCustomClass.MyValidationFunc()) { e.Style.TextColor = dateOKColor; } else { e.Style.TextColor = dateForbiddenColor; } e.Style.CellTipText = dateOrTenorModel.Tip; updateFormatting = false; } base.OnPrepareViewStyleInfo(e); }
There must be a better way. Any ideas?
Thanks, Steve
>Hi Steve,
In your custom cell renderer, you can subscribe the QueryCellInfo event and set the TextColor of the cell using this event. Below are the code snippet
this.Grid.Model.QueryCellInfo += new GridQueryCellInfoEventHandler(HandleQueryCellInfo);
HAhaneefm Syncfusion Team July 10, 2007 09:54 PM UTC
Hi Steve,
The reason is that you are using the OnPrepareViewStyleinfo event. OnPrepareviewStyleInfo method does not store any styleInfo properties in a grid. It just set the visual apperence of the grid. It depends on the data stored in a grid. If you want to set as well as store the style of the cell, then you can handle the QueryCellInfo event of the grid.