SubGroup Headers with no items

Hey guys,

I'm only recently introduced to SyncFusion, and am massively impressed so far, but I'm stuck on one particular troublesome issue.

I am building an app that will be just a tiered SfListView, showing sports event details.

  • Sport
  • Competition
  • Event
  • Details about event


The "Details about event" bit will more than likely end up on its own page / not in the list, but the rest of them, they'll be a "simple" list view.

Problem occurs here.  At startup, the app connects to my server, and only then queries for sports.  I've followed the "hack" here -> https://www.syncfusion.com/kb/8491/how-to-display-group-header-without-items-and-add-items-in-the-group-at-run-time about how to show group headers in a list, when you've no items.

That works without a problem when you've only 1 tier, but when you've multiple tiers like this (Sport - Competition - Event), it gets messy.

Basically at startup, when I get the sports, I don't have all the definitions for each competition for each sport, and the way the backend works, I don't want it to, either.  I have it working so that when you tap the sport, it shows a small loading bar, and then queries the backend for all competitions for that sport.  And as you'd expect, when you tap the competition, you get all its events, when you tap the event, you get all its details / go to a new page for that event.

I have all the tap / load stuff working right, and I nearly have the list view working basically how I want, except for one issue.  When I add my "dummy" sports, for the sport group headers, they have "Competition" set to "".  When I add my "dummy" competitions, for the competition group headers, they have "Event" set to "".

What that ends up like is attached.  When you expand a sport, it shows the competitions correctly, but then also shows a blank header, for the dummy sport item, which had Competition set to "".  When you expand a competition, you get the same again, a blank header for the dummy competition item, which had Event set to "".

I have now tried absolutely everything to stop this from happening, but no matter what I try (including some painful hacks with reflection), I can't get this working right.

My main point / question is, can I either very specifically state what are the group headers, and that's it, no more are automatically created, *or* can I prevent any blank headers from being added / shown, headers with GroupResults where they key is ""?



Attachment: Screen_Shot_20180523_at_17.03.30.png_4fe91337.zip

5 Replies

Séadna May 24, 2018 01:30 AM UTC

Ok, so I've found a solution (although it initially seems a bit buggy) - after I've populated the list with "real" items, I delete the dummy ones.

I've an ObservableCollection "AllRows", which stores all the rows, so if I expand a sport, if it has populated that with competitions, I then delete all the dummy ones who had competition set to "".  If I expand a competition, if it has populated that with events, I then delete all the dummy ones who had event set to "", and same with event and event details.

It is still a bit buggy (though that could have been other stuff I've been trying), and it *definitely* feels hacky and unnecessary, so I still absolutely would prefer a better solution.


Séadna May 24, 2018 10:35 AM UTC

And just to update again, the buggy-ness I was experiencing was due to doing all the bits with the DataSource of the SfListView in "one shot", i.e. add a number of headers, then remove a blank header.  This was causing an internal array out of bounds exception.

To solve this, when I'm iterating the list of headers to remove, I call ListView.RefreshView before removing the header.  Things are now working absolutely as expected.

It's still definitely a hack, and I'd still like an alternative option, but I now have a working thing I can move on from.


MK Muthu Kumaran Gnanavinayagam Syncfusion Team May 24, 2018 10:53 AM UTC

Hi Séadna, 
 
We have checked the reported query “Need for empty SubGroupHeaders in SfListView” from our side. We would like to let you know that the GroupHeader items will be created based on the PropertyName or Key value specified in GroupDescriptors for each items. Our KB documentation showcases an workaround to achieve empty groups by adding a dummy item initially inside the groups and collapsing its height initially. So if your requirement to achieve the same using Multi-Level grouping, you need to remove that dummy item so that there wont be any blank groups created for that item. This blank group is due to its item’s empty Key value. Only possible workaround is to delete the dummy items while adding new items in that group as you have mentioned. 
 
Regards, 
G.Muthu kumaran.    



OE Ocean Enterprises February 24, 2021 07:55 AM UTC

What kind of sports event showing to you? I am searching for details about watersport events.


LN Lakshmi Natarajan Syncfusion Team February 25, 2021 05:46 AM UTC

Hi Ocean, 
 
Greetings from Syncfusion. 
 
Could you please explain your requirement regarding Syncfusion controls in detail to check further from our side? It will be helpful for us to check on it and provide you the solution as soon as possible.a 
 
Lakshmi Natarajan 
 


Loader.
Up arrow icon