|
Query 1: if it´s possible to conditional format a cell based on the higher and lower values of a specific column that has real time updates |
You can apply the style based on higher and lower cell value in RealTime update by writing style to GridCell using CellStyle property in GridColumn as like below code example.
| ||
|
Query 2: I would like to use those values to calculate and show a proportional progress bar inside the cell. |
You can display the progress bar inside the cell using CellTemplate property in GridColumn as like below code example.
|
Hi,
Thank you for replying.
Forgot to mention that I currently don't keep track of the higher and lowest values. In your sample code, the 15.0 value is unknown.
Could I use a multi binding instead and pass a value from the Summary Table Row?
Thank you!
Edson.
|
<syncfusion:GridTextColumn MappingName="PreviousClose" TextAlignment="Right" >
<syncfusion:GridTextColumn.CellStyleSelector>
<local:SelectorClass />
</syncfusion:GridTextColumn.CellStyleSelector>
</syncfusion:GridTextColumn> |
|
public class SelectorClass : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
var dataGrid = (container as GridCell).ColumnBase.GridColumn.GetType().
GetProperty("DataGrid", BindingFlags.NonPublic | BindingFlags.Instance).GetValue((container as GridCell).ColumnBase.GridColumn,null);
//You can get the TableSummaryRow value from RowData of tableSummaryRow
var tableSummaryRow = (dataGrid as SfDataGrid).RowGenerator.Items.Find(element => element.RowType == RowType.TableSummaryRow);
var value = (tableSummaryRow.RowData as SummaryRecordEntry).SummaryValues[0].AggregateValues.Values.ElementAt(0);
var data = item as StockData;
if (data != null && value!=null)
{
//you can apply conditional formatting based on TaleSummaryRow here.
if (double.Parse(data.PreviousClose.ToString()) < double.Parse(value.ToString()))
return App.Current.Resources["redCellStyle"] as Style;
else
return App.Current.Resources["blueCellStyle"] as Style;
}
return base.SelectStyle(item, container);
}
} |