I migrated from Listview to Collectionview and I have 2 problems. Can you help me? 1- Is it possible to hide the group indicator? 2- This blank space appears at the end of the layout. In the Listview everything is ok, but in the CollectionView I couldn't identify it. Do you know what it could be?
1 Answer, 1 is accepted
0
Yana
Telerik team
answered on 12 Jul 2024, 09:36 AM
Hi Rodrigo,
Both issues can be resolved by creating a GroupViewStyle for the CollectionView:
1 - the group indicator is added into the GroupView ControlTemplate, so you'd need to override it to remove it.
2 - this is the padding set inside the GroupViewStyle.
Perfect! Thanks. If I want it to always be expanded when someone clicks on the grouping, what should I do?
Regards,
Rodrigo.
Lance | Senior Manager Technical Support
Telerik team
commented on 12 Jul 2024, 05:21 PM
| edited
Hi Rodrigo,
If I understand you correctly, you don't want a specific group to be collapsed if it is expanded and the user taps it? There isn't a setting right now where you can define an exact group to not be collapsible.
However I have an idea that you can try that achieves the same end result.
When a group is tapped, it will trigger the GroupTapped event. Inside this event you can get a reference to the group's context; see if the IsExpanded=false and the group's name. If all conditions match, then programmatically re-expand it.
Here's an example to explain better:
privateasyncvoidRadCollectionView_OnGroupTapped(object sender, RadTappedEventArgs<GroupContext> e)
{
// Get the references we needvar collectionView = sender as RadCollectionView;
var dataView = collectionView.GetDataView();
// If the group is currently expanded and the group's title is "Belgium"if (!e.Data.IsExpanded && e.Data.Key.ToString() == "Belgium")
{
// Find the matching IDataGroupvar matchingGroup = dataView.GetGroups().FirstOrDefault(g => g.Key == e.Data.Key);
// You need a very short delay to allow the previous change's animationawait Task.Delay(20);
// Re-expand it
dataView.ExpandGroup(matchingGroup);
}
}
While this does have a very quick collapse/expand animation, it will force that group to stay open and achieves the ultimate goal.
Outside of this, we would need to build in an GroupTapping pre-trigger event that allows you to call some sort of e.Cancel() method to cancel the operation. I will mention this desire to the dev team to consider for future planning.
[Edit] Fixed misspelling and grammar to better clarify the suggestion.
Hi Rodrigo, I spoke with the devs and indeed my recommendation is the only suitable path right now. I did open this Feature Request on your behalf for them to consider adding something more official in time => [CollectionView] Add Cancellation support for group expand/collapse.