Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Scroll to Appointment in Calendar via Code (Read 5545 times)
Brock
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 8
Joined: Jun 1st, 2015
Scroll to Appointment in Calendar via Code
Aug 27th, 2019 at 8:40pm
Print Post  
Hello,

It's been awhile. Anyway, I have a search feature in our calendar and I'd like to scroll to the appointment matching the search. I am able to determine which appt matches the search but I can't figure out how to programmatically scroll the calendar to the desired appointment.

The calendar has dates on X axis and resources (employees) on the Y axis. The Y axis resource might have multiple appointments on the same date, so the calendar needs to programmatically scroll vertically and horizontally.

If I could get a coordinate Point from the appointment then have the calendar scroll to it, that would be ideal. Or at least figure the scroll position changes from the current scroll pos to the appointment scroll pos.

Any help is appreciated. thanks




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


tech.support

Posts: 3500
Joined: Oct 19th, 2005
Re: Scroll to Appointment in Calendar via Code
Reply #1 - Aug 28th, 2019 at 8:24am
Print Post  
Hi,

Try calling the Calendar.ensureVisible(Item) method.

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


I Love MindFusion!

Posts: 8
Joined: Jun 1st, 2015
Re: Scroll to Appointment in Calendar via Code
Reply #2 - Aug 28th, 2019 at 3:35pm
Print Post  
Thank you for the quick response.

That does scroll the X axis but it does not scroll the Y axis.
For example, the employee may be at the bottom of the calendar and not visible since I am at the top of the calendar.  When used, I can see the x scroll to position, but the appointment is not visible yet since it is at the bottom of the calendar.  I still have to manually scroll down.

I am using the the resource view with the lane style if that matters.

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


tech.support

Posts: 3500
Joined: Oct 19th, 2005
Re: Scroll to Appointment in Calendar via Code
Reply #3 - Aug 29th, 2019 at 5:29am
Print Post  
It scrolls vertically too in my test, the Resources sample project modified like this -

Code
Select All
for (int i = 0; i < 40; i++)
{
	app = new Appointment();
	last = app;
	app.setStartTime(DateTime.op_Addition(calendar.getDate(), Duration.fromDays(13)));
	app.setEndTime(DateTime.op_Addition(app.getStartTime(), Duration.fromHours(66)));
	app.setHeaderText("Resource " + i);
	app.getContacts().add(calendar.getContacts().get(r.nextInt(3)));
	calendar.getSchedule().getItems().add(app);
}
calendar.endInit();

content.add(calendar);

JButton button = new JButton();
button.setText("ensure");
content.add(button);

button.addActionListener(new ActionListener()
{
	@Override
	public void actionPerformed(ActionEvent e)
	{
		calendar.ensureVisible(last);
	}
}); 



Let me know what I should change to reproduce not scrolling. I'm trying this with latest 2.0.1 release.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Brock
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 8
Joined: Jun 1st, 2015
Re: Scroll to Appointment in Calendar via Code
Reply #4 - Aug 29th, 2019 at 9:14pm
Print Post  
Yes that's what we have code wise. We do have two resources, primary and secondary, and these settings as well.

      getCalendar().setSecondaryGroupType(GroupType.GroupByResources);
      getCalendar().setGroupType(GroupType.GroupByResources);
      getCalendar().setCustomDraw(CustomDrawElements.All);
      getCalendar().getResourceViewSettings().getTopTimelineSettings().setUnitCount(30
0);
      getCalendar().getResourceViewSettings().setEnableCollisions(true);
      getCalendar().getResourceViewSettings().setAllowResizeRowHeaders(true);
      getCalendar().getResourceViewSettings().setSnapUnit(TimeUnit.Day);
      getCalendar().getResourceViewSettings().setSnapUnitCount(1);
      getCalendar().getResourceViewSettings().setViewStyle(ResourceViewStyle.Lanes);

I'd send more code but it is difficult to extract it from the embedded app. We have extended on it heavily to integrate with our system. It works great BTW!

It is moving the X scrollbar, so it is getting called and doing something. I think the double resource is causing an issue with the Y scrollbar.

As far as version, I do a version call to from calendar.getSchedule().CurrentVersion and get 7? The date on the .jar is 12/1/14 if that's an indication. The JDK is based on AdoptOpen JDK 8u212b3

Thanks!


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


tech.support

Posts: 3500
Joined: Oct 19th, 2005
Re: Scroll to Appointment in Calendar via Code
Reply #5 - Aug 30th, 2019 at 1:28pm
Print Post  
That's probably version 1.1 but it worked too in my test, attached to the post. Clicking the 'ensure' buttons brings the last item 39 into view. I've tried it with Oracle's JDK 8 on Windows 10.
  

resources2.zip (Attachment deleted)
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint