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

Filterpredicate with Add New Row

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.

1 Reply

JP Jagadeesan Pichaimuthu Syncfusion Team May 24, 2019 03:48 AM

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. 

Live Chat Icon For mobile
Up arrow icon