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
close icon

Filtering

A couple of questions,

1 - is there a way to change the default item in the Advanced Filter combo from "equals" to "contains".

2 - Using filtering with paging, I can get the view
      grid.View as Syncfusion.UI.Xaml.Grid.GridPagedCollectionViewWrapper;
   which then has a TotelItemCount property, which maintains the total count of items, this is useful as it is correct after the filter is applied. However it is marked as obselete so I wondered what is the correct way now to get the filtered data count?

Thanks, and best wishes to everyone at Syncfusion for the holiday period :)



7 Replies

SA Saravanan Ayyanar Syncfusion Team December 23, 2019 12:58 PM UTC

Hi Tom,   
   
Thank you for using Syncfusion control.   
   
Query 1:   
   
By default, SfDataGrid having three types of advance filter type (Text, Numeric and DateTime). Text filter has "contains filter". Numeric and DateTime filter does not have this “Contains” filter, so could you please share your exact requirement? It will help us to provide the better solution.   
   
Query 2:   
   
We have checked your requirement in our end and marked TotalItemCount property as obsolete for internal purpose in our source. You can get the data count by using the ItemCount property. Please refer to the below code example   
   
Code Snippet:   
var view = this.dataGrid.View as Syncfusion.UI.Xaml.Grid.GridPagedCollectionViewWrapper;   
var count = view.ItemCount;               
   
Please refer to the sample for the same from the link below   
  
Sample Link:    
   
Please let us know, if you require further assistance on this.   
   
Regards,   
Saravanan A. 



TO Tom December 30, 2019 10:55 AM UTC

1 - Yes I meant for the Text chooser - the dropdown boxes are both set as default to "Equals" and I want to change that to "Contains"
2 - thank you, yes ItemCount seems to be the same.
     One slight problem I notice is that, I am using a datapager with the grid. If i have filters set on the grid, and I then change the itemsource to another dataset, the data that is      displayed in the grid is correctly filtered, but this ItemCount / TotalItemCount number is wrong. Ie the grid might display 10 records but the ItemCount is 150 (the      unfiltered coun). I can workaround this by clearing the filters and re-adding them, which forces the ItemCount to be correct again, but it would be great if this step wasn't      necessary.


SA Saravanan Ayyanar Syncfusion Team December 31, 2019 11:17 PM UTC

Hi Tom, 
 
Thanks for your update. 
 
Query 1: 
 
We are currently working on this with high priority. We will update you with further details on January 02, 2020. We appreciate your patience until then.   
 
Query 2: 
 
We are not clear with your query. You are using different event  for to set the item source and to get the item count or you reset the item source in one event, that same event to get the item count ? Can you please provide more details about your query. 
 
It will be helpful for us to investigate further. 
 
Regards, 
Saravanan A. 



SA Saravanan Ayyanar Syncfusion Team January 2, 2020 12:52 PM UTC

Hi Tom, 
 
Thank you for using Syncfusion control. 
 
Query 1: 
 
You can achieve your requirement to change the Contains filter type as default value in GridTextColumn by customize the style of AdvanceFilterControl. Please refer the below code snippet. 
 
<Style x:Key="popupstyleforCustomerName" TargetType="Syncfusion:GridFilterControl"> 
     <Setter Property="FilterMode" Value="Both" /> 
     <Setter Property="AdvancedFilterStyle" Value="{StaticResource advancedfilterstyleforCustomerName}" /> 
</Style> 
 
<Syncfusion:GridTextColumn HeaderText="Customer Name"   FilterPopupStyle="{StaticResource popupstyleforCustomerName}" MappingName="CustomerName" /> 
 
 
Sample Link: 
 
Please let us know, if you require further assistance on this. 
 
Regards, 
Saravanan A.


TO Tom January 3, 2020 11:36 AM UTC

1 - Great, thanks for that

2 - So DataGrid with DataPager. Bind ItemSource in Code. Use a Text Column filter, e.g. limit "Customer Name" to Contains "John", then it displays correctly and the itemcount is correct. However if you now change the ItemSource to another collection, the "John" filter is still applied, and the data in the grid reflects that. However the ItemCount property is the number of items without the filter applied. However if (in code) i just remove and re-add the column filters, the item count property is then correct. Sorry I can't explain it better than that, and the workaround is fine, especially as it is not clear whether one should expect the same filters to be applied when changing the ItemSource anyway.


SA Saravanan Ayyanar Syncfusion Team January 6, 2020 02:09 PM UTC

Hi Tom, 
 
Thank you for your update. 
 
Query 2: 
Currently we are checking your reported scenario. We will validate this and provide you details on January 8, 2020. We appreciate your patience until then. 
 
Regards, 
Saravanan A. 



SA Saravanan Ayyanar Syncfusion Team January 8, 2020 02:20 PM UTC

Hi Tom, 
 
Thank you for using Syncfusion Control. 
 
We are able to reproduce the reported scenario in our end. It occurs since the view is not refreshed after the ItemsSource is set. You can resolve  this by getting the view Item Count from Dispatcher.BeginInvoke method in datagrid. Please refer the below code snippet. 
 
private void Button_Click(object sender, System.Windows.RoutedEventArgs e) 
{ 
    this.sfDataPager.Source = respository.PopulateOrders(10); 
    this.dataGrid.ItemsSource = this.sfDataPager.PagedSource; 
    this.dataGrid.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.ApplicationIdle, 
            new Action(() => 
            { 
                var view = this.dataGrid.View as Syncfusion.UI.Xaml.Grid.GridPagedCollectionViewWrapper; 
                var count = view.ItemCount; 
            })); 
} 
 
 
 
Sample Link: 
 
We hope it helps, please let us know if you need further assistance on this. 
 
Regards, 
Saravanan A. 


Loader.
Live Chat Icon For mobile
Up arrow icon