- Home
- Forum
- Xamarin.Forms
- Grouping doesn't work- SfListView
Grouping doesn't work- SfListView
This is my XAML:
This is basically the same as the one given in the SfListViewSample.<Grid>
<listView:SfListView x:Name="listView" ItemSize="65" GroupHeaderSize="60"
ItemsSource="{Binding UsersList}" ItemSpacing="0,0,5,0"
AllowGroupExpandCollapse="True"
IsStickyGroupHeader="True">
<listView:SfListView.DataSource>
<dataSource:DataSource>
<dataSource:DataSource.GroupDescriptors>
<dataSource:GroupDescriptor PropertyName="Group"/>
</dataSource:DataSource.GroupDescriptors>
</dataSource:DataSource>
</listView:SfListView.DataSource>
<listView:SfListView.GroupHeaderTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout BackgroundColor="#E4E4E4">
<Label Text="{Binding Key}"
FontSize="22"
FontAttributes="Bold"
VerticalOptions="Center"
HorizontalOptions="Start"
Margin="20,0,0,0" />
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</listView:SfListView.GroupHeaderTemplate>
<listView:SfListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
---------
</ViewCell.View>
</ViewCell>
</DataTemplate>
</listView:SfListView.ItemTemplate
</listView:SfListView>
</Grid>
Am I missing something here? I just copied the XAML code from working fine example of contacts from the example provided by SyncFusion.private ObservableCollection<UserDetails> _users;public ObservableCollection<UserDetails> UsersList{get { return _users; }set{_users= value;RaisePropertyChanged(() => UsersList);}}
Hi Customer,Thank you for using Syncfusion products.Query 1:We have analyzed the reported query with the given code snippet and we suspect that the issue may arise with the Group property which has bind to the GroupDescriptor. Can you please check whether you have provided data to Group property because if the group’s Key value is null, groups are not created. The group header contains GroupResult(Contains the Key and grouped items based on the property which has bind to GroupDescriptor) as binding context and other than binding context, it won’t bind the data. So, we recommend you to group the items based on property in the Model class which has underlying data. For your reference, we have prepared an sample as like your code snippet in which Model class is not implemented with INotifyPropertyChanged interface and bind the Group property to GroupDescriptor’s PropertyName and the group headers are created properly. You can download the sample from the below link.Could you please check with the sample?. If you face any issue, please modify the above sample to reproduce the issue and update us with replication procedure. So, that we could able to analyze the issue better and update you with appropriate solution.Query 2:Currently SfListView do not have support for “HasUnevenRows”. We have already considered this as feature request and we are implementing the feature “Automatically fit the item height based on content” and it will be available in our upcoming 2017 Volume 1 SP 2 release which is scheduled to be rolled out by end of this month.Please let us know if you require further assistance.Regards,Dinesh Babu Yadav
Okay, I finally got the grouping to work when the page is loaded initially- by setting the visibility only after the list has been loaded.... but when i edit an item, post the details to the server... (i can also edit the category that was used to group the list)...get an updated list as response..... the grouping headers vanish. What is the issue?
Hi Customer,Sorry for the inconvenience caused.We have confirmed that the issue with “GroupHeader is not updated when groupdescriptor is removed and then added at runtime in UWP platform” is a defect and we have logged a defect report. The fix for the reported issue will be available in our upcoming 2017 Volume 1 SP 2 release which is scheduled to be rolled out by end of this month. We will appreciate your patience until then.Please let us know if you require further assistance.Regards,Dinesh Babu Yadav
As for me, the header is not at all shown. And I have just tested it in Android.
|
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e)
{
if (e.ItemData is GroupResult)
return;
viewModel.Contactsinfo.Remove(e.ItemData as Contacts);
}
private void RemoveItemInGroup_Clicked(object sender, EventArgs e)
{
var item = listView.DataSource.DisplayItems[1] as Contacts;
viewModel.Contactsinfo.Remove(item as Contacts);
DisplayAlert("Add Item in Group", "Added Item is " + item.Name + item.Group, "Ok");
} |
- Can you share the SfListView version? We have tested in latest version(v15.1.0.37).
- In which ListView LayoutManager you have tested? We have tested in both Linear Layout and GridLayout.
- Can you share the Xamarin Form version? We have tested in (v2.3.3.180).
- If possible, can you please modify the sample which replicates the issue?
Hi Customer,Apologies for the delay caused.We have analyzed the reported issue “Group header gets cleared when underlying data is removed at runtime” with the given information at different possible scenarios in our sample. In the sample, we have removed the item from the underlying collection by a button click and on tapping the ListViewItem as like below code snippet. But we didn’t face any issue. For your reference, we have attached the sample and you can download the same from the below link.Code Example[C#]
private void ListView_ItemTapped(object sender, Syncfusion.ListView.XForms.ItemTappedEventArgs e){if (e.ItemData is GroupResult)return;viewModel.Contactsinfo.Remove(e.ItemData as Contacts);}private void RemoveItemInGroup_Clicked(object sender, EventArgs e){var item = listView.DataSource.DisplayItems[1] as Contacts;viewModel.Contactsinfo.Remove(item as Contacts);DisplayAlert("Add Item in Group", "Added Item is " + item.Name + item.Group, "Ok");}Could you please check with the above sample?. If the issue still reproduces at your end, please modify the above sample 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 share the below details?
- Can you share the SfListView version? We have tested in latest version(v15.1.0.37).
- In which ListView LayoutManager you have tested? We have tested in both Linear Layout and GridLayout.
- Can you share the Xamarin Form version? We have tested in (v2.3.3.180).
- If possible, can you please modify the sample which replicates the issue?
Please let us know if you require further assistance.Regards,Dinesh Babu Yadav
Okay.
I'm experiencing the same issue like bg. I have SfListView on Page 1. I open detail of ListView item on Page 2. On Page 2 I can do some modifications on item, so when I return to Page 1 I need to refresh data. In OnAppearing of Page 1 I call Refresh (method in view model which reloads Items - ItemSource of ListView). And then the group headers disappear. I tried it with ObservableCollection, List, always calling OnPropertyChanged and nothing helped.
- Binding empty collection to ItemsSource property.
- While set ItemsSource as ‘null’
- While clearing the underlying collection.
- What are the settings that you have applied for SfDataGrid?
- How are you grouping the columns? Are you using custom grouping?
- Is it possible to share your XAML code for our reference to replicate the issue in our side?
We have checked your requirement "Item display binding in sfpicker" from our side.
This can be achieved with SelectedItem API and In IOS there is an issue at SelectedItem binding. The fix for the reported SelectedItem binding will be available in our upcoming 2018 Volume 1 release.
Please let us know if you have any other query.
Regards,
Sivaraman
- 14 Replies
- 7 Participants
-
BG bg
- Mar 8, 2017 04:57 AM UTC
- Feb 13, 2018 11:41 AM UTC