How to set MaxValue of a GridNumericColumn to a dynamic value
I have a data grid with (amongst others) a numeric column. Each or it's rows has been bound to an instance of a LevelDataRow using the grid's ItemsSource property. The column's column mapping has been bound to a property called Spill. So the column definition currently looks like this:-
The thing is the Max value should not be a static value of 9999. It needs to be a dynamic value calculated for each Row. A simple property to calculate the MaxValue would like this:-
I can't seem to work out how use that function to set the MaxValue on the column. Something a bit like this:-
Any suggestions?
xaml Code:
<sf:GridNumericColumn HeaderText="Spill (Ml/d)" AllowEditing="True" NumberDecimalDigits="2" MappingName="Spill" CellStyle="{StaticResource SpillCellStyle}" MinValue="0" MaxValue="9999"/>
The thing is the Max value should not be a static value of 9999. It needs to be a dynamic value calculated for each Row. A simple property to calculate the MaxValue would like this:-
C# Code:
public double MaxSpill { get { return Volume - m_reservoirWrapper.Capacity; } }
I can't seem to work out how use that function to set the MaxValue on the column. Something a bit like this:-
xaml Code:
<sf:GridNumericColumn HeaderText="Spill (Ml/d)" AllowEditing="True" NumberDecimalDigits="2" MappingName="Spill" CellStyle="{StaticResource SpillCellStyle}" MinValue="0" MaxValue="{Binding Path=MaxSpill, Mode=OneWay}"/>
Any suggestions?
SIGN IN To post a reply.
4 Replies
SA
Saravanan Ayyanar
Syncfusion Team
December 19, 2019 01:39 PM UTC
Hi Declan Hillier,
Thank you for using Syncfusion control.
We have prepared the sample based on your requirement. You can able to bind the different MaxValue in each row of GridNumericColumn. Here you should override the class GridNumericCellRenderer and GridNumericColumn.
Please find the sample link below
Sample Link:
Please let us know, if you require further assistance on this.
Regards,
Saravanan A.
DH
Declan Hillier
December 19, 2019 02:12 PM UTC
Thank you. This is tremendously helpful.
DH
Declan Hillier
December 19, 2019 02:58 PM UTC
I'm working my way through the code and believe I mostly understand it.
However, I get an error when I try to run it. I change a value in a cell and this line of code:-
"customColumn.MaxValue = customColumn.MaxValueSelector.GetMaxValue(dataContext);"
...in GridCellNumericRendererExt.OnInitializeEditElement is throwing the following error:-
"Unable to cast object of type 'Syncfusion.UI.Xaml.Grid.GridCell' to type 'System.Windows.Controls.TextBlock"
SA
Saravanan Ayyanar
Syncfusion Team
December 20, 2019 10:47 AM UTC
Hi Declan Hillier,
We have analyzed your query related the following error “Unable to cast object of the type Syncfusion.UI.Xaml.Grid.GridCell to type System.Windows.Controls.TextBlock” but the issue not reproduced its works at our end. So could you please check the below video location.
Sample Video Link:
If still you are facing the same issue, please revert us with more details on replication/video illustration of the issue. Also if possible, please revert us with the modified sample. It will helps us to investigate further and provide earlier prompt solution.
Please let us know, if you require further assistance on this.
Regards,
Saravanan A.
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
DH Declan Hillier
- Dec 18, 2019 10:09 AM UTC
- Dec 20, 2019 10:47 AM UTC