How to group SfListView when ItemSource is a DataTable?

Hello,

I followed this post https://www.syncfusion.com/kb/9697/how-to-bind-data-from-the-datatable-to-listview-in-xamarin-forms and sucessfully show a DataTable using SfListView.

Then I tried to group data with one of its column using :

<syncfusion:SfListView.DataSource>
      <dataSource:DataSource>
        <dataSource:DataSource.GroupDescriptors>
          <dataSource:GroupDescriptor PropertyName="ContactType">
            <dataSource:GroupDescriptor.Comparer>
              <local:CustomGroupComparer/>
            </dataSource:GroupDescriptor.Comparer>
          </dataSource:GroupDescriptor>
        </dataSource:DataSource.GroupDescriptors>
      </dataSource:DataSource>
    </syncfusion:SfListView.DataSource>
  </syncfusion:SfListView>
The code above doesn't work.  I also tried

   <dataSource:GroupDescriptor PropertyName="{Binding ItemArray[0]}">
This also doesn't work. The app throwed  Object reference not set to an instance of an object exception 

If the DataSource is a IEnumerable then the grouping works fine.

Please advise how to correctly identify the Column Name for grouping when DataSource is a DataTable?

Thank You.




3 Replies

CS Chandrasekar Sampathkumar Syncfusion Team June 8, 2020 07:24 PM UTC

Hi Tung, 
Thank you using Syncfusion products. 
We have checked the reported query “How to group SfListView when ItemSource is a DataTable?” from our end. We could replicate the reported scenario on our side. We would like to let you know that there is no support for your requirement in DataSource. 
Reg. If the DataSource is a IEnumerable then the grouping works fine. 
Can you please share the code snippets for our reference. 
Chandrasekar Sampathkumar 



TU Tung June 10, 2020 11:09 PM UTC

> Reg. If the DataSource is a IEnumerable then the grouping works fine. 
> Can you please share the code snippets for our reference. 
Sorry for the mistake here. I mean: If the ItemsSource is a List of objects instead of a DataTable, then the grouping works fine.
I just replaced the DataTable  by a List of Objects.





CS Chandrasekar Sampathkumar Syncfusion Team June 11, 2020 05:50 PM UTC

Hi Tung, 
Thank you for the update. 
#Regarding If the ItemsSource is a List of objects instead of a DataTable, then the grouping works fine. 
We would like to let you know that in article 9697, ListView ItemsSource is an ObservableCollection<object> but mentioned as DataTable.  
Can you please share the following details which would be helpful or us to check on it and provide you solution at the earliest, 
  • Are you removing DataTable and using List<Object> instead of ObservableCollection<object>?
  • Code snippets of ListView Data Population
Regards, 
Chandrasekar Sampathkumar 


Loader.
Up arrow icon