Possible to hide expand button and empty group?

1 Answer 17 Views
ListView
Willy
Top achievements
Rank 2
Iron
Iron
Willy asked on 02 Jun 2022, 03:03 PM

Hello, I just have a simple question is it possible to remove the expand arrow? I just want the group to always display all the items without the option to collapse. Also, I have some items which are not in a group because the column they are grouped by is empty. Is it possible to hide the group area for these? 

 

 

 

Thank you

 

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 03 Jun 2022, 09:43 AM

Hello, Willy, 

If you want to hide the expand/collapse arrow for the groups in RadListView you can use the following code snippet in the VisualItemFormatting event:

        private void radListView1_VisualItemFormatting(object sender, ListViewVisualItemEventArgs e)
        {
            SimpleListViewGroupVisualItem groupItem= e.VisualItem as SimpleListViewGroupVisualItem;
            if (groupItem != null)
            {
                //hide the group arrow
                groupItem.ToggleElement.Visibility = ElementVisibility.Collapsed;
            }
        }

As to the question about the group size, note that RadListView offers the GroupItemSize property. Thus, you can specify the desired height for the group item. However, it affects all the group items. However, if you set the AllowArbitraryItemHeight property to true, the groups with empty text will be almost invisible:

        public RadForm1()
        {
            InitializeComponent();

            this.radListView1.VisualItemFormatting += radListView1_VisualItemFormatting;
            for (int i = 0; i < 10; i++)
            {
                this.radListView1.Items.Add("Item" + i);
            }
            radListView1.EnableCustomGrouping = true;
            radListView1.ShowGroups = true;
            ListViewDataItemGroup docGroup = new ListViewDataItemGroup("Documents");
            ListViewDataItemGroup diskGroup = new ListViewDataItemGroup("");
            radListView1.Groups.Add(docGroup);
            radListView1.Groups.Add(diskGroup);
            foreach (ListViewDataItem item in radListView1.Items)
            {
                if (radListView1.Items.IndexOf(item) % 2 == 0)
                {
                    item.Group = docGroup;
                }
                else
                {
                    item.Group = diskGroup;
                }
            }
            this.radListView1.AllowArbitraryItemHeight = true;
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Willy
Top achievements
Rank 2
Iron
Iron
commented on 03 Jun 2022, 02:24 PM

Thank you that solved my issues. 
Tags
ListView
Asked by
Willy
Top achievements
Rank 2
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or