This is a migrated thread and some comments may be shown as answers.

Groups of items in RadGridView are expanded automatically

3 Answers 381 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Egor
Top achievements
Rank 1
Egor asked on 01 Jun 2017, 02:46 PM

Hello, I have RadGridView and grouped items in it. I want to collapse the groups and I can do it. But if any property of item will be changed, the group contains this item will be expanded automatically. I want this group to be expanded regardless of the property changes. Is it bug or feature of RadGridView? Tell me, please, how I can fix it?

I wanted to attach archive with sample project. But forum allows me to attach pictures only

3 Answers, 1 is accepted

Sort by
0
Egor
Top achievements
Rank 1
answered on 01 Jun 2017, 02:52 PM
This is code that reproduce my problem
 
<telerik:RadGridView x:Name="MyRadGridView"
                     AutoExpandGroups="True"
                     AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name, Mode=OneWay}" />
        <telerik:GridViewDataColumn DataMemberBinding="{Binding Index, Mode=OneWay}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>
01.
public partial class MainWindow : Window
02.{
03.    private readonly Random _random = new Random();
04.    private readonly List<Item> _items;
05. 
06.    public MainWindow()
07.    {
08.        InitializeComponent();
09. 
10.        _items = new List<Item>
11.        {
12.            new Item() { Name = "First", GroupName = "A group" },
13.            new Item() { Name = "Second", GroupName = "A group" },
14.            new Item() { Name = "Third", GroupName = "B group" },
15.            new Item() { Name = "Fourth", GroupName = "B group" },
16.            new Item() { Name = "Fifth", GroupName = "B group" },
17.        };
18. 
19.        var itemView = new ListCollectionView(_items);
20.        itemView.GroupDescriptions.Add(new PropertyGroupDescription("GroupName"));
21. 
22.        MyRadGridView.ItemsSource = itemView;
23. 
24.        Observable.Interval(TimeSpan.FromSeconds(1))
25.                  .Subscribe(OnNext);
26.    }
27. 
28.    private void OnNext(long l)
29.    {
30.        foreach (var item in _items)
31.        {
32.            item.Index = _random.Next(10);
33.        }
34.    }
35.}
01.public class Item : INotifyPropertyChanged
02.{
03.    #region Name
04. 
05.    private string _name;
06. 
07.    public string Name
08.    {
09.        get { return _name; }
10.        set
11.        {
12.            _name = value;
13.            RaisePropertyChanged("Name");
14.        }
15.    }
16. 
17.    #endregion
18. 
19.    #region GroupName
20. 
21.    private string _groupName;
22. 
23.    public string GroupName
24.    {
25.        get { return _groupName; }
26.        set
27.        {
28.            _groupName = value;
29.            RaisePropertyChanged("GroupName");
30.        }
31.    }
32. 
33.    #endregion
34. 
35.    #region Index
36. 
37.    private int _index;
38. 
39.    public int Index
40.    {
41.        get { return _index; }
42.        set
43.        {
44.            _index = value;
45.            RaisePropertyChanged("Index");
46.        }
47.    }
48. 
49.    #endregion
50. 
51.    public event PropertyChangedEventHandler PropertyChanged;
52. 
53.    [NotifyPropertyChangedInvocator]
54.    protected virtual void RaisePropertyChanged(string propertyName)
55.    {
56.        var handler = PropertyChanged;
57.        if (handler != null)
58.            handler(this, new PropertyChangedEventArgs(propertyName));
59.    }
60.}
0
Accepted
Yoan
Telerik team
answered on 05 Jun 2017, 10:04 AM
Hi Egor,

Can you try setting RadGridView's GroupRenderMode property to "Flat"? This mode represents our new virtualization mechanism with a completely new item container generator. It should resolve your problem.

I hope this helps. If you need further assistance, do not hesitate to contact us again.

Regards,
Yoan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Egor
Top achievements
Rank 1
answered on 05 Jun 2017, 10:10 AM
It helps. Thank you, Yoan)
Tags
GridView
Asked by
Egor
Top achievements
Rank 1
Answers by
Egor
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or