Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Advice for adding A LOT of items to resources on the calendar (Read 1138 times)
Michael Hopkins
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Apr 5th, 2022
Advice for adding A LOT of items to resources on the calendar
Aug 16th, 2022 at 8:52pm
Print Post  
Hi,

I am dealing with a lot of items being displayed on the calendar and I am wondering if there is any advice/best practice for adding a lot of items on the calendar.

Right now, we go to the DB and ask for all the items for many employees. If there are a lot of items to display, it can take up to 20 seconds (1000+ items) to draw the items on the calendar.

What is the best way to put the 1000 items onto the calendar so that the user does not have to wait that long.

Right now we do this.

Code
Select All
calendar.schedule.items.addAll(itemNodeList) 



Is the best practice to do it this way, or should we chunk the items and add them in batches?

Is there a recommended upper limit of items to be put on the calendar.

Thanks,

Michael

  
Back to top
 
IP Logged
 
Slavcho
God Member
*****
Offline


tech.support

Posts: 3159
Joined: Oct 19th, 2005
Re: Advice for adding A LOT of items to resources on the calendar
Reply #1 - Aug 17th, 2022 at 6:57am
Print Post  
Hi,

Try enclosing resource and appointment loading code within beginInit / endInit. E.g. modified ResourceTimeline example creates 1000 items over 150 resources for less than a second in my test:

Code
Select All
calendar.beginInit();
...
for (int i = 0; i < 50; i++)
{
	// Create some contacts
	Contact contact = new Contact();
	contact.setFirstName("Douglas");
	contact.setLastName("Clark");
	calendar.getContacts().add(contact);

	contact = new Contact();
	contact.setFirstName("Jayna");
	contact.setLastName("Silversteed");
	calendar.getContacts().add(contact);

	contact = new Contact();
	contact.setFirstName("Joe");
	contact.setLastName("Timberwood");
	calendar.getContacts().add(contact);
}

Appointment app = null;
Random r = new Random();

for (int i = 0; i < 1000; i++)
{
	app = new Appointment();
	app.setStartTime(DateTime.op_Addition(calendar.getDate(), Duration.fromDays(r.nextInt(10) + 3)));
	app.setEndTime(DateTime.op_Addition(app.getStartTime(), Duration.fromHours(24 + r.nextInt(24))));
	app.setHeaderText("Resource " + i);
	app.getContacts().add(calendar.getContacts().get(r.nextInt(3 * 50)));
	calendar.getSchedule().getItems().add(app);
}

calendar.endInit();
 



Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Michael Hopkins
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Apr 5th, 2022
Re: Advice for adding A LOT of items to resources on the calendar
Reply #2 - Aug 17th, 2022 at 7:04pm
Print Post  
Thanks for the response!

I double checked if we are calling begininit and endinit and we are. We are adding these items on the fly after the calendar date has been changed. (IE When they move to the next week on a timetable view)

My logs:
FLAG: Beginning init
FLAG: Adding all new items (1348) took 16856 Milliseconds
FLAG: ending init

All 1348 items can be seen on the calendar at that time. (if I grow the columns so that not all items are being shown it makes it significantly faster)

Any other advice for me?

Thanks
  
Back to top
 
IP Logged
 
Michael Hopkins
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 23
Joined: Apr 5th, 2022
Re: Advice for adding A LOT of items to resources on the calendar
Reply #3 - Aug 17th, 2022 at 10:52pm
Print Post  
UPDATE:

We found a little hack that improves significantly the time it takes to add 1000+ items to the calendar.

As noted earlier, when we make the columns small on the calendar and try to load all the items, it would take like 15+ seconds but if the columns were normal sized, it would only be like 4ish seconds.

So we had the bright idea to set the visible columns to 1, add the columns to the calendar, and then set the visible columns back to whatever it was. Doing that improved the speed a TON. It went from 15+ seconds to less than 2 seconds.

Code
Select All
calendar.beginit()
val columns = calendar.getTimetableSettings().getVisibleColumns();
calendar.getTimetableSettings().setVisibleColumns(1)
calendar.getSchedule().getItems().addAll(newItems);
calendar.getTimetableSettings().setVisibleColumns(columns);
calendar.endinit()
 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint