📅  最后修改于: 2023-12-03 15:02:20.784000             🧑  作者: Mango
jqxScheduler
is a powerful and customizable jQuery-based scheduler with support for various features such as multiple views, recurring events, resources, and locales. The ensureVisible()
method is a key functionality provided by the jqxScheduler
API which helps to ensure that the specified date or resource is visible in the scheduler viewport.
ensureVisible(date: Date | string, resourceId?: any)
This method doesn't return any value.
// get the jQWidgets jqxScheduler instance
var scheduler = $('#scheduler').jqxScheduler('getInstance');
// ensure that the current date (today) is visible in the scheduler
scheduler.ensureVisible(new Date());
// ensure that a particular date is visible in the scheduler
scheduler.ensureVisible('2021-09-25');
// ensure that a particular resource is visible in the scheduler
scheduler.ensureVisible(new Date(), 'resource-1');
When ensureVisible()
is called with a valid date
parameter, the method calculates the position of the date in the scheduler viewport and adjusts the viewport accordingly. If the resourceId
parameter is also specified, the method calculates the position of the resource in the scheduler and adjusts the viewport.
Internally, the ensureVisible()
method uses the scrollTo()
method to adjust the scheduler viewport position. The scrollTo()
method is a built-in method of the jqxScrollBars
class, which is used by the jqxScheduler
component to handle scrolling. When the scrollTo()
method is called with a valid position
parameter, it updates the scrollbar position and adjusts the viewport position accordingly.
The ensureVisible()
method provided by jqxScheduler
is a useful feature that helps you ensure that a particular date or resource is visible in the scheduler viewport. This method is particularly useful when you need to programmatically navigate to a specific date or resource in the scheduler.