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

problem filtering

Hi, i am using Filtering control, i dont use MMVM becouse my project have only 2 pages. I use code behind. 
The problem its when i filter the list sort the items that i filter up in the list and the list show all others items that i dont filter and the scroll dont appear. It's so strange .  

I am a full beginner this is my code, i appreciate if i can have a sample code different to the xample that its in essential studio becouse its to dificult to understand


XAM
    <StackLayout Orientation="Horizontal">                
                <SearchBar x:Name="filterText"
                                Grid.Row="0"
                                Grid.Column="0"
                                IsVisible="true"
                                Placeholder="Search here to filter"
                                TextChanged="OnFilterTextChanged">         
            </SearchBar>
        </StackLayout>
        <listView:SfListView x:Name="listView" >
        </listView:SfListView>

Code behind

    public TestPageList()
        {

            InitializeComponent();

            listView.ItemTemplate = new DataTemplate(typeof(GameCell));
            listView.ItemSize = 60;

            LoadGames();
      
        }

        SearchBar searchBar = null;

        private void OnFilterTextChanged(object sender, TextChangedEventArgs e)
        {
            searchBar = (sender as SearchBar);

            if (listView.DataSource != null)
            {
    
                listView.DataSource.Filter = FilterGames;
           
                listView.DataSource.RefreshFilter();
            }              
        }

        private bool FilterGames(object obj)
        {
            if (searchBar == null || searchBar.Text == null)
                return true;

            var taskInfo = obj as StatGame;

            if (taskInfo.YourDeck.ToLower().Contains(searchBar.Text.ToLower())
                 || taskInfo.YourDeck.ToLower().Contains(searchBar.Text.ToLower()))
                return true;
            else
                return false;
        }


        private IList<StatGame> list()
        {
            using (var da = new DataAccess())
            {
                var list = da.GetList<StatGame>(true).ToList();
                return list;

            }
        }

        private void LoadGames()
        {
            using (var da = new DataAccess())
            {
                var list = da.GetList<StatGame>(true).ToList();
                var total = list.Sum(l => l.MyResult);
                listView.ItemsSource = list;
                listView.ItemSize = 60;

            }
        }

Note: StatGame its a SQLite table class.


3 Replies

DB Dinesh Babu Yadav Syncfusion Team March 6, 2017 10:08 AM UTC

Hi Felique, 
 
Thank you for using Syncfusion products. 
 
We have checked the reported issue “Filtering is not working” at our end, but we were unable to reproduce the issue with our sample. In the sample, we have used the SQLite table to fetch the data from the database and define it to the ItemsSource property and filtered the items in the SearchBar as like your code snippet but we didn’t face any issue. For your reference we have attached the sample and you can download same from the below link.  
   
 
If the issue still reproduces at your end, please modify the above samples to reproduce the issue and update us with replication procedure or video link. So, that we could able to analyze the issue better and update you with appropriate solution. And also, can you please share the below details? 
 
  • Whether the issue reproduces only in specific platform like Android or others too?
  • Can you share your SfListView version? We have tested in our latest SfListView version(v15.1.0.37).
 
For more information about filtering, you can refer the below UG documentation link. 
 
Please let us know if you have any concern.   
 
Regards, 
Dinesh Babu Yadav 



FE Felique March 13, 2017 06:32 PM UTC

I am very Happy the example show perfect how to use the SfListView control, my problem was that i dont add the  Syncfusion.SfListView.XForms.Android in the droid project.
Thanks a lot.


DB Dinesh Babu Yadav Syncfusion Team March 14, 2017 03:36 AM UTC

Hi Felique, 
 
Thanks for the update. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Live Chat Icon For mobile
Up arrow icon