This is a migrated thread and some comments may be shown as answers.
Collapse ListView Groups by default
6 Answers 65 Views
This is a migrated thread and some comments may be shown as answers.
Mano Sadeh
Top achievements
Rank 1
Mano Sadeh asked on 01 Oct 2018, 04:05 PM

Hey

Can we initialize RadListView control with Grouping that all groups are collapsed by default?

Thanks,

Mano

6 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 01 Oct 2018, 05:27 PM
Hello Mano,

There's no initialization property that does this, however you can achieve the same effect by programmatically collapsing the groups. See here for more information: Expand and Collapse Groups.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Иван
Top achievements
Rank 1
answered on 02 Oct 2018, 02:25 PM
I added next code:

lvWorkTasks.PropertyChanged += LvWorkTasks_PropertyChanged;

        private void LvWorkTasks_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName.Equals("ItemsSource"))
            {
                lvWorkTasks.GetDataView().CollapseAll();
            }
        }

But when CollapseAll method is called then null reference exception appears for Items property.
0
Lance | Manager Technical Support
Telerik team
answered on 02 Oct 2018, 03:12 PM
Hi Ivan,

I see that you opened a support ticket for the same question and my colleague has replied. I will share the reason you're having that problem, along with the solution, here with the community as well.

Problem:
Using the Xamarin.Forms PropertyChanged event handler, to check when ItemsSource has changed, is too soon in the lifecycle because the native control's items haven't had a chance to be populated yet.

Solution:
You can instead use the NativeControlLoaded event, which will fire when the native TKExtendedListView control is ready.

// event subscription (can also be done in XAML)
listView.NativeControlLoaded += listView_NativeControlLoaded;
 
// event handler
private void listView_NativeControlLoaded(object sender, EventArgs e)
{
    var dataView = this.listView.GetDataView();
 
    dataView.CollapseAll();
}


Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Иван
Top achievements
Rank 1
answered on 02 Oct 2018, 03:37 PM
The same exception in that case
System.NullReferenceException: 'Object reference not set to an instance of an object.' 
0
Lance | Manager Technical Support
Telerik team
answered on 02 Oct 2018, 03:42 PM
Hi Ivan,

If you're continuing to see that behavior, there is likely another factor specific to how your application loads data.

Run the demo we sent you in the ticket to see that it works as expected using the recommendation. Then, update the demo so that it replicates the exception and send it back to Didi in that ticket thread for further investigation. She will be able to investigate directly and provide a more appropriate solution for that scenario.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Parvez
Top achievements
Rank 1
answered on 14 Nov 2019, 11:23 AM

what work around i did.. because its giving me the count zero , so again i am checking it after full list get loaded. May be this will help you.

public SubSectionEquipmentPage()
        {
            InitializeComponent();
            MyListView.NativeControlLoaded += MyLisView_NativeControlLoaded;
        }

        private void MyLisView_NativeControlLoaded(object sender, System.EventArgs e)
        {
            CollapseList();
        }

        public async void CollapseList()
        {
            var dataView = this.MyListView.GetDataView();
            if (dataView != null && dataView.Items.Count>0)
            {
                dataView.CollapseAll();
            }
            else
            {
                await Task.Delay(2000);
                CollapseList();
            }
        }

Asked by
Mano Sadeh
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Иван
Top achievements
Rank 1
Parvez
Top achievements
Rank 1
Share this question
or