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

Data load very slow or no filtering. Need Help !

Adds data using datatable. How to add filtering or how to speed up loading to table using eg ObservableCollection.(1 row + open activity - dt = 3sec is ok, OC = 20 sec)

3 Replies

SS Sivaraman Sivagurunathan Syncfusion Team June 1, 2017 03:21 AM UTC

Hi Przemyslaw Kolodziejski, 
 
Thanks for contacting Syncfusion Support. 
 
Regarding your first query(Data load very slow): 
 
We have checked your query and prepared sample for your requirement. But we are unable to reproduce the issue in our side. We have checked the loading time of SfDataGrid with 1000 rows and the grid takes 890ms in simulator and 1052ms in device. We have attached a sample for your reference and you can download the same from below link. 
 
 
Regarding your second query: 
 
We have checked your query. You can add the filtering while using DataTable as Itemsource. It can achieve by using RowFilter property. 
 
The below code illustrates how to add filtering in SfDataGrid while using DataTable. 
 
public class MainActivity : Activity 
{ 
    SfDataGrid sfGrid; 
    FilteringViewModel viewModel; 
    SearchView filterText; 
    protected override void OnCreate(Bundle bundle) 
    { 
        base.OnCreate(bundle); 
        LinearLayout linear = new LinearLayout(this); 
        linear.Orientation = Orientation.Vertical; 
        sfGrid = new SfDataGrid(this); 
        sfGrid.ColumnSizer = ColumnSizer.Star; 
        viewModel = new FilteringViewModel(this); 
        viewModel.SetRowstoGenerate(100); 
        sfGrid.ItemsSource = new GridDataTableCollectionViewExt(this.sfGrid, (IEnumerable)viewModel.DataTable.DefaultView); 
        filterText = new SearchView(this); 
        filterText.SetQueryHint("Enter the Text to filter"); 
        filterText.QueryTextChange += OnFilterTextChanged; 
        viewModel.filtertextchanged = OnFilterChanged; 
        linear.AddView(filterText); 
        linear.AddView(sfGrid); 
        SetContentView(linear); 
    } 
    void OnFilterChanged() 
    { 
        if (sfGrid.View != null) 
        { 
            var rowfilter = string.Empty; 
            for (int i = 0; i < this.sfGrid.Columns.Count; i++) 
            { 
                var colfilter = string.Empty; 
                colfilter = colfilter.Predicate(this.sfGrid.Columns[i].MappingName, filterText.Query, FilterType.Contains); 
                if (string.IsNullOrEmpty(rowfilter)) 
                    rowfilter = "(" + colfilter + ")"; 
                else 
                    rowfilter = rowfilter.OrPredicate() + "(" + colfilter + ")"; 
            } 
            (this.sfGrid.View as DataTableCollectionView).ViewSource.RowFilter = rowfilter; 
            this.sfGrid.View.RefreshFilter(); 
        } 
    } 
 
    void OnFilterTextChanged(object sender, SearchView.QueryTextChangeEventArgs e) 
    { 
        viewModel.FilterText = (sender as SearchView).Query.ToString(); 
    } 
} 
 
public class GridDataTableCollectionViewExt : GridDataTableCollectionViewWrapper 
{ 
    public GridDataTableCollectionViewExt(SfDataGrid dataGrid, IEnumerable source) 
                                            : base(source, dataGrid) 
    { 
    } 
    public override void RefreshFilter(bool isProgrammatic) 
    { 
    } 
} 
 
We have prepared sample for your requirement and have attached the sample for your reference. You can download the same from the below link. 
 
 
Regards, 
Sivaraman  
 



PK Przemyslaw Kolodziejski June 1, 2017 10:02 AM UTC

Thanks !!!
Best solution for Lenovo Yoga Book is DataTable


SS Sivaraman Sivagurunathan Syncfusion Team June 5, 2017 03:16 AM UTC

Hi Przemyslaw Kolodziejski,   
 
Thanks for the update.

Please let us know if you require further assistance on this.
 
Regards, 
Sivaraman 


Loader.
Live Chat Icon For mobile
Up arrow icon