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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Filterpredicate with Add New Row

Thread ID:





144816 May 24,2019 03:26 AM UTC May 24,2019 08:48 AM UTC WinForms 1
Tags: SfDataGrid
Asked On May 24, 2019 03:26 AM UTC

I am trying to add a new row with a filter predicate. I am running into the issue when I run a filter predicate first, it won't let me add a new row because the ID I set isn't included in the filter. Is there a way to set that ID value when trying to add a new row. 

For instance:

 sfDataGrid1.Columns["taskID"].FilterPredicates.Add(new FilterPredicate() { FilterType = FilterType.Equals, FilterValue = taskID });

Now when I have the Add new Row, it won't work because the taskID is set to null when you create a new entry.

Jagadeesan Pichaimuthu [Syncfusion]
Replied On May 24, 2019 08:48 AM UTC

Hi Julius, 
Thanks for using Syncfusion product. 
Your requirement can be achieved by initializing the values in add new row by using the AddNewRowInitiating event. By using this event, you can initialize some default values to any column in AddNewRow. Please refer the below code snippet for your reference. 
sfDataGrid.AddNewRowInitiating += sfDataGrid_AddNewRowInitiating; 
void sfDataGrid_AddNewRowInitiating(object sender, Syncfusion.WinForms.DataGrid.Events.AddNewRowInitiatingEventArgs e) 
    var data = e.NewObject as ProductSalesDetails; 
    data.TaskID = 109; 
We have prepared the sample to achieve your requirement with adding the new row based on the filter value. 
You can refer the below documentation link for your reference. 
If we misunderstood your requirement, please provide more information regarding the requirement. This would help us to proceed further. 


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