Hey
Can we initialize RadListView control with Grouping that all groups are collapsed by default?
Thanks,
Mano
6 Answers, 1 is accepted
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
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.
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
System.NullReferenceException: 'Object reference not set to an instance of an object.'
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
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();
}
}