SfDataGrid currentcellvalidation

Hello,

I have a SfDataGrid bound by an Observable Collection. One of the columns is of type GridTextColumn, and is mapped to data of type Object.
The data represented in the column on display for the user "appears" as an Integer.

The user should be able to edit the field, change the "Integer" and move on. However, when the user attempts to leave the field, cell validation is failing with the error:

"The input value is not a valid value for System.Object"

While I understand the error, changing the mapped data to type Integer overcomes this error, however, the type has to remain Object.
How can I use the event sfdatagrid_CurrentCellValidating to overcome this error and validate the entered data by the user as an Integer but store the data as an Object? Or, is there a better event to use for the validation?

I have searched the forums and reviewed the documentation, but cannot find a solution.
Looking for some assistance. Thank you.

12 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team November 27, 2020 12:50 PM UTC

Hi Stoked,

Thank you for contacting Syncfusion support.

Based on provided information we have checked the reported issue “The input value is not a valid value for System.Object while SfDataGrid currentcellvalidation” and unable to replicate the issue from our end. it is working fine as expected. Please find the tested sample and video demo from our end in the below link,

Sample link: https://www.syncfusion.com/downloads/support/forum/160088/ze/CurrentCellValidating1586800706 
We have checked with Syncfusion product version 18.3.0.47.

Can you please share us below things?       
        1. Brief replication procedure/video illustration of the reported issue
        2. Provide the code snippet related customization in SfDataGrid?
        3. Provide code snippet related to data loaded for mapped to Object type?   
        4. Provide code snippet related to customization in CurrentCellValidating event?               
     
if you still facing the same issue? If yes, please modify the sample based on your scenario. 

It will be helpful for us to check on it and provide you the solution at the earliest.

Regards,
Vijayarasan S 



ST Stoked November 30, 2020 05:56 AM UTC

Thank you for the video and the example. Let me review my code and I will update this thread with my observations.

-- updated --

Here is what I've got, since I cannot attach a document...

// here is my definition
public class METRIC
{
public class RECORD
{
public object UnitPrice { get; set; }
}
}

// the collection in which i store the data collected from the database, which is then added to the datasource for SfDataGrid
private readonly ObservableCollection AllMetrics = new ObservableCollection();

// my column definition for the affected column
{
    SfDataGrid.Columns.Add(new GridTextColumn()
    {
        HeaderText = "UnitPrice",
        MappingName = "UnitPrice",
        CellStyle = new CellStyleInfo() { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Center },
        MinimumWidth = 75,
        AllowEditing = true,
        AllowFiltering = false,
        Visible = true
    });

That is all of the code that I can supply at this time. If there is anything further that you require, please let me know.

I have also attached 2 pics. The first, showing the loaded value, 24.
The second pic showing an attempt to change 24 to 25 with the validation error message shown.




-----

Edit: I've also changed the SfDataGrid ValidtionMode to None, and I still get the error indicated if that helps. My understanding from this article, https://help.syncfusion.com/windowsforms/datagrid/datavalidation, was that validationmode of None meant that built-in validation is disabled. This appears to not be the case.

-----

Edit #2: If I change the type from:

public object UnitPrice { get; set; }

to:

public int UnitPrice { get; set; }

...I can edit the contents of the cell and validation works. Shouldn't type object accept anything in that cell/field?

-----

Edit #3: changing the column type from GridTextColumn to GridNumericColumn also results in "The input value is not a valid value for System.Object" error.


VS Vijayarasan Sivanandham Syncfusion Team November 30, 2020 03:32 PM UTC

Hi Stoked,

Thanks for the update.

We could able to reproduce your reported issue “The input value is not a valid value for System.Object” from our end. Currently, we are checking the feasibility to fix this issue from our end. We will validate and update you details on or before December 02, 2020. 
We appreciate your patience until then.

Regards,
Vijayarasan S
 



VS Vijayarasan Sivanandham Syncfusion Team December 2, 2020 05:03 PM UTC

Hi Stoked,

Sorry for the inconvenience caused.

We are currently working on your requirement of “The input value is not a valid value for System.Objec” but we get some technical issue based on our source architecture and we need further analysis in our SfDatagrid source architecture. We will validate and update you the details on December 04, 2020.

Regards,
Vijayarasan S



VS Vijayarasan Sivanandham Syncfusion Team December 4, 2020 03:30 PM UTC

Hi Stoked,

Thank you for your patience.

We have created bug report for the reported issue ”System.Object validation error show while committing cell value mapped with Object type in GridColumn in SfDataGrid”. Can you please confirm, which version you are using currently?

It will be helpful for us to provide patch in that version.

Regards,
Vijayarasan S



ST Stoked December 4, 2020 04:12 PM UTC

Currently using version 18.2.0.44. Thank you.


VS Vijayarasan Sivanandham Syncfusion Team December 7, 2020 02:29 PM UTC

Hi Stoked,

Thanks for the update.

We have created bug report for the reported issue “System.Object validation error show while committing cell value mapped with Object type in GridColumn in SfDataGrid”. We will fix this issue and provide you with patch on December 21, 2020.

You can track the status of this report through the following feedback link,

Feedback link: https://www.syncfusion.com/feedback/20347/system-object-validation-error-show-while-committing-cell-value-mapped-with-object

Note: The provider feedback link is private, and you need to login to view this feedback.

We appreciate your patience until then.

Regards,
Vijayarasan S 



VS Vijayarasan Sivanandham Syncfusion Team December 21, 2020 02:51 PM UTC

Hi Stoked, 
 
Thank you for your patience. 
 
We have fixed the issue “System.Object validation error show while committing cell value mapped with Object type in GridColumn” and fixed the issue. You can download the patch from following location.  
  v18.2.0.44 
Recommended approach – exe will perform automatic configuration       
Please find the patch setup here:   

 

Advanced approach – use only if you have specific needs and can directly replace existing assemblies for your build environment                       
 
Please find the patch assemblies alone from: 

 
Please find the NuGet’s from the below location: 

 
  
Assembly Version: 18.2.0.44 
Installation Directions:  
This patch should replace the files “Syncfusion.SfDataGrid.Winforms” under the following folder.  
$system drive:\ Files\Syncfusion\Essential Studio\$Version # \precompiledassemblies\$Version#\4.0  
Eg : $system drive:\Program Files\Syncfusion\Essential Studio\18.2.0.44\precompiledassemblies\18.2.0.44\4.0  
   
To automatically run the Assembly Manager, please check the Run assembly manager checkbox option while installing the patch. If this option is unchecked, the patch will replace the assemblies in precompiled assemblies’ folder only. Then, you will have to manually copy and paste them to the preferred location, or you will have to run the Syncfusion Assembly Manager application (available from the Syncfusion Dashboard, installed as a shortcut in the Application menu) to re-install assemblies. 

Feedback Link:
https://www.syncfusion.com/feedback/20347/system-object-validation-error-show-while-committing-cell-value-mapped-with-object 
 
Note:  
To change how you receive bug fixes, ask your license management portal admin to change your project’s patch delivery mode.  
   
   
Disclaimer:  
If you have received other patches for the same version for other products, please apply all patches in the order received. Please note that we have created this patch for version 18.2.0.44 specifically to resolve the following issue reported in the forum 160088. 
 
Regards, 
Vijayarasan S 



ST Stoked December 21, 2020 03:04 PM UTC

Thank you. I look forward to verifying this over the coming days.
Moving forward, is this fix going to be applied in a future release? If so, which one can I expect that to be in?


ST Stoked December 22, 2020 04:45 AM UTC

The provided fix is working as expected. Please let me know which release will contain this fix so I can upgrade accordingly. Thanks.



VS Vijayarasan Sivanandham Syncfusion Team December 22, 2020 01:34 PM UTC

Hi Stoked,

Thanks for the update. 
Based on provided information your reported issue “System.Object validation error show while committing cell value mapped with Object type in GridColumn”. In this fix we will included in our upcoming Essential Studio 2020 Volume 4 SP release which is expected on end of January 2020. 
We appreciate your patience until then.  

Regards,
Vijayarasan S 



VS Vijayarasan Sivanandham Syncfusion Team February 1, 2021 07:04 AM UTC

Hi Stoked,

Thank you for your patience.

We are glad to announce that our Essential Studio 2020 Volume 4 Service Pack Release v18.4.0.39 is rolled out with the reported bug fix “System.Object validation error show while committing cell value mapped with Object type in GridColumn” and is available for download under the following link.

 
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.

 
Regards,
Vijayarasan S 


Marked as answer
Loader.
Up arrow icon