We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set MaxValue of a GridNumericColumn to a dynamic value

Thread ID:

Created:

Updated:

Platform:

Replies:

150026 Dec 18,2019 10:09 AM UTC Dec 20,2019 10:47 AM UTC WPF 4
loading
Tags: SfDataGrid
Declan Hillier
Asked On December 18, 2019 10:09 AM UTC

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:-
xaml Code:
  1. <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:
  1. 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:
  1. <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?

Saravanan Ayyanar [Syncfusion]
Replied On 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. 


Declan Hillier
Replied On December 19, 2019 02:12 PM UTC

Thank you.  This is tremendously helpful.

Declan Hillier
Replied On 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"


Saravanan Ayyanar [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon