jQWidgets jqxScheduler cellDoubleClick事件

yizhihongxing

jQWidgets是一套基于jQuery的快速开发Web应用程序的UI库,提供了大量的可继承的UI部件和插件,其中之一是jqxScheduler控件。jqxScheduler是一个功能强大的基于可编辑日历的Web日历控件,提供了许多有用的日程管理和日历显示功能,例如:显示工作/空闲状态、日历导航、事件编辑器等。而cellDoubleClick事件则是jqxScheduler控件的一个重要事件之一,此事件会在用户在jqxScheduler控件上双击某个日期单元格时触发,本文将详细讲解如何使用“jQWidgets jqxScheduler cellDoubleClick事件”。

一、事件说明

jqxScheduler控件的cellDoubleClick事件具有以下属性:

  1. event - {Object} - 事件对象。

  2. appointment - {Object} - 对应日期单元格的预约对象。

  3. $target - {jQuery Object} - 事件触发的jQuery对象。

二、事件绑定

使用jqxScheduler控件的cellDoubleClick事件时,必须将事件绑定到现有的jqxScheduler控件上。您可以使用以下代码为jqxScheduler控件绑定cellDoubleClick事件:

$('#scheduler').on('cellDoubleClick', function (event) {
  // Handle the event here.
});

此代码将为ID为“scheduler”的具有jqxScheduler插件的元素添加cellDoubleClick事件回调。在事件回调函数中,您可以访问cellDoubleClick事件的属性。

三、示例说明

在以下示例中,我们将创建一个具有jqxScheduler控件的演示页面,并在该控件上显示某个时间段内的事件。并演示在当时双击日期单元格时会触发cellDoubleClick事件的情况。

示例1

以下示例演示了如何在jqxScheduler控件上显示包括事件和周/工作日视图,并处理cellDoubleClick事件。

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>示例1:jqxScheduler控件演示</title>

    <!-- 引入jQWidgets的CSS和JavaScript文件 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxdatetimeinput.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxscheduler.js"></script>

    <style>
        #scheduler {
            margin: 10px;
            width: 95%;
            height: 500px;
        }
    </style>

    <script type="text/javascript">
        $(document).ready(function () {
            // Initialize the jqxScheduler control.
            $('#scheduler').jqxScheduler({
                width: '100%',
                height: '100%',
                theme: 'energyblue',
                source: [],
                appointmentDataFields: {
                    from: 'start',
                    to: 'end',
                    id: 'id',
                    description: 'description',
                    location: 'location',
                    subject: 'subject',
                    resourceId: 'calendar',
                    backgroundColor: 'backgroundColor',
                    borderColor: 'borderColor'
                },
                views: [
                    'dayView',
                    'weekView',
                ],
                view: 'weekView',
                showLegend: true,
                resources: {
                    colorScheme: 'scheme04',
                    dataField: 'calendar',
                    source: new $.jqx.dataAdapter({
                        localData: [
                            { id: '3', calendar: 'Red', borderColor: '#FF0000', backgroundColor: '#FFCCCC' },
                            { id: '4', calendar: 'Blue', borderColor: '#0000FF', backgroundColor: '#CCCCFF' },
                            { id: '5', calendar: 'Green', borderColor: '#008000', backgroundColor: '#CCFFCC' }
                        ],
                        dataType: 'array'
                    })
                }
            });

            // Bind to the cellDoubleClick event.
            $('#scheduler').on('cellDoubleClick', function(event) {
                var args = event.args;
                var $target = $(args.$target);
                var appointment = args.appointment;

                alert("Double-clicked on cell " + $target.attr('id') + " with appointment id " + appointment.id);
            });

            // Load sample data.
            var appointments = [
                {
                    id: '1',
                    subject: "Meeting with team",
                    description: "Meet to discuss project plan.",
                    location: "Meeting Room 1",
                    calendar: '4',
                    backgroundColor: '#CCCCFF',
                    borderColor: '#0000FF',
                    start: new Date(2019, 1, 21, 9, 0, 0),
                    end: new Date(2019, 1, 21, 11, 0, 0)
                },
                {
                    id: '2',
                    subject: "Meeting with customer",
                    description: "Meet to discuss project details.",
                    location: "Meeting Room 2",
                    calendar: '3',
                    backgroundColor: '#FFCCCC',
                    borderColor: '#FF0000',
                    start: new Date(2019, 1, 27, 10, 0, 0),
                    end: new Date(2019, 1, 27, 12, 0, 0)
                },
                {
                    id: '3',
                    subject: "Demo",
                    description: "Present project demo.",
                    location: "Meeting Room 3",
                    calendar: '5',
                    backgroundColor: '#CCFFCC',
                    borderColor: '#008000',
                    start: new Date(2019, 1, 28, 10, 0, 0),
                    end: new Date(2019, 1, 28, 11, 0, 0)
                }
            ];

            $('#scheduler').jqxScheduler({
                source: new $.jqx.dataAdapter({
                    dataFields: [
                        { name: 'id', type: 'string' },
                        { name: 'description', type: 'string' },
                        { name: 'location', type: 'string' },
                        { name: 'subject', type: 'string' },
                        { name: 'calendar', type: 'string' },
                        { name: 'backgroundColor', type: 'string' },
                        { name: 'borderColor', type: 'string' },
                        { name: 'start', type: 'date', format: 'yyyy-MM-dd HH:mm' },
                        { name: 'end', type: 'date', format: 'yyyy-MM-dd HH:mm' }
                    ],
                    localData: appointments
                })
            });
        });
    </script>
</head>

<body>
    <h1>示例1:jqxScheduler控件演示</h1>
    <div id="scheduler"></div>
</body>

</html>

示例2

以下示例演示如何在jqxScheduler控件上显示包括事件和月视图,并处理cellDoubleClick事件。

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>示例2:jqxScheduler控件演示</title>

    <!-- 引入jQWidgets的CSS和JavaScript文件 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxdatetimeinput.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/5.6.0/jqwidgets/jqxscheduler.js"></script>

    <style>
        #scheduler {
            margin: 10px;
            width: 95%;
            height: 500px;
        }
    </style>

    <script type="text/javascript">
        $(document).ready(function () {
            // Initialize the jqxScheduler control.
            $('#scheduler').jqxScheduler({
                width: '100%',
                height: '100%',
                theme: 'energyblue',
                source: [],
                appointmentDataFields: {
                    from: 'start',
                    to: 'end',
                    id: 'id',
                    description: 'description',
                    location: 'location',
                    subject: 'subject',
                    resourceId: 'calendar',
                    backgroundColor: 'backgroundColor',
                    borderColor: 'borderColor'
                },
                views: [
                    'dayView',
                    'weekView',
                    'monthView'
                ],
                view: 'monthView',
                showLegend: true,
                resources: {
                    colorScheme: 'scheme04',
                    dataField: 'calendar',
                    source: new $.jqx.dataAdapter({
                        localData: [
                            { id: '3', calendar: 'Red', borderColor: '#FF0000', backgroundColor: '#FFCCCC' },
                            { id: '4', calendar: 'Blue', borderColor: '#0000FF', backgroundColor: '#CCCCFF' },
                            { id: '5', calendar: 'Green', borderColor: '#008000', backgroundColor: '#CCFFCC' }
                        ],
                        dataType: 'array'
                    })
                }
            });

            // Bind to the cellDoubleClick event.
            $('#scheduler').on('cellDoubleClick', function(event) {
                var args = event.args;
                var $target = $(args.$target);
                var appointment = args.appointment;

                alert("Double-clicked on cell " + $target.attr('id') + " with appointment id " + appointment.id);
            });

            // Load sample data.
            var appointments = [
                {
                    id: '1',
                    subject: "Meeting with team",
                    description: "Meet to discuss project plan.",
                    location: "Meeting Room 1",
                    calendar: '4',
                    backgroundColor: '#CCCCFF',
                    borderColor: '#0000FF',
                    start: new Date(2019, 1, 21, 9, 0, 0),
                    end: new Date(2019, 1, 21, 11, 0, 0)
                },
                {
                    id: '2',
                    subject: "Meeting with customer",
                    description: "Meet to discuss project details.",
                    location: "Meeting Room 2",
                    calendar: '3',
                    backgroundColor: '#FFCCCC',
                    borderColor: '#FF0000',
                    start: new Date(2019, 1, 27, 10, 0, 0),
                    end: new Date(2019, 1, 27, 12, 0, 0)
                },
                {
                    id: '3',
                    subject: "Demo",
                    description: "Present project demo.",
                    location: "Meeting Room 3",
                    calendar: '5',
                    backgroundColor: '#CCFFCC',
                    borderColor: '#008000',
                    start: new Date(2019, 1, 28, 10, 0, 0),
                    end: new Date(2019, 1, 28, 11, 0, 0)
                }
            ];

            $('#scheduler').jqxScheduler({
                source: new $.jqx.dataAdapter({
                    dataFields: [
                        { name: 'id', type: 'string' },
                        { name: 'description', type: 'string' },
                        { name: 'location', type: 'string' },
                        { name: 'subject', type: 'string' },
                        { name: 'calendar', type: 'string' },
                        { name: 'backgroundColor', type: 'string' },
                        { name: 'borderColor', type: 'string' },
                        { name: 'start', type: 'date', format: 'yyyy-MM-dd HH:mm' },
                        { name: 'end', type: 'date', format: 'yyyy-MM-dd HH:mm' }
                    ],
                    localData: appointments
                })
            });
        });
    </script>
</head>

<body>
    <h1>示例2:jqxScheduler控件演示</h1>
    <div id="scheduler"></div>
</body>

</html>

本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:jQWidgets jqxScheduler cellDoubleClick事件 - Python技术站

(0)
上一篇 2023年5月11日
下一篇 2023年5月11日

相关文章

  • 如何使用JavaScript/jQuery禁用HTML链接

    当我们需要禁用HTML链接时,可以通过JavaScript或jQuery来实现。 使用JavaScript禁用HTML链接 使用JavaScript禁用HTML链接需要获取所有需要禁用的链接(一般通过class或id来获取),然后对其添加一个click事件。在click事件中调用preventDefault()方法来阻止链接默认跳转行为。 下面是一个示例代码…

    jquery 2023年5月12日
    00
  • 当元素被点击时,通过添加类名来切换类,当点击外部时,删除类

    要实现当元素被点击时通过添加类名来切换类,当点击外部时删除类,可以使用以下步骤: 第一步:添加点击事件 使用 addEventListener 方法添加元素的点击事件,当元素被点击时触发对应的事件处理函数。 const element = document.querySelector(‘.element’); element.addEventListener…

    jquery 2023年5月13日
    00
  • jQuery Validate插件实现表单验证

    下面是关于“jQuery Validate插件实现表单验证”的完整攻略。 一、什么是jQuery Validate插件 jQuery Validate是一个简单易用的jQuery表单验证插件,它可以实现各种常见的表单验证功能,如必填、长度验证、数字验证、邮箱验证、手机号验证、密码强度验证等等。 二、使用jQuery Validate插件 使用jQuery V…

    jquery 2023年5月28日
    00
  • jQWidgets jqxTree checkAll()方法

    以下是关于 jQWidgets jqxTree checkAll() 方法的完整攻略: jQWidgets jqxTree checkAll() 方法 checkAll() 方法用于选中树形结构中的所有节点。该方法不接受任何参数。 语法 jqxTree’).jqxTree(‘checkAll’); 示例 以下两个示例,演示如何使用 checkAll() 方法…

    jquery 2023年5月11日
    00
  • jQWidgets jqxTagCloud rtl属性

    $jQWidgets是一款非常流行的Web前端UI框架,其中jqxTagCloud是其提供的一个标签云控件,可以方便地展示一系列标签列表。rtl属性是jqxTagCloud控件的一个重要属性,用于控制标签云的文字方向。下面我将详细介绍jqxTagCloud和rtl属性的使用方法。 jqxTagCloud的基本用法 首先,我们需要在HTML页面中引入jQWid…

    jquery 2023年5月12日
    00
  • jQWidgets jqxBarGauge宽度属性

    jQWidgets jqxBarGauge宽度属性 jQWidgets是一个基于jQuery的UI组件库,提供了丰富的UI件和工具,包括表格、图表、历、菜单等。jqxBarGauge是jQWidgets中的一个组件,可以用水平或垂直的条形。jqxBarGauge提供了width属性,用于设置条形图的宽度。 width属性的基本语法 width属性用于设置条形…

    jquery 2023年5月9日
    00
  • jQWidgets jqxTreeGrid ensureRowVisible()方法

    jQWidgets jqxTreeGrid ensureRowVisible()方法 jqxTreeGrid 是 jQWidgets 提供的一个树形表格组件,它可以展示层级结构的数据支持多种交互操作。jqxTreeGrid 提供了 ensureRowVisible() 方法,用于确指定行可见。 ensureVisible()方法 ensureRowVisib…

    jquery 2023年5月11日
    00
  • jQuery源码分析之Event事件分析

    下面我将详细讲解“jQuery源码分析之Event事件分析”的完整攻略。 概述 jQuery是一个开源的JavaScript库,提供了大量的方法和函数,简化了JavaScript在网页中处理操作的难度。Event事件是jQuery中的一个重要的模块,提供了对DOM元素事件进行绑定和解绑的方法,使得页面交互更加丰富。本攻略将对jQuery中的Event事件模块…

    jquery 2023年5月18日
    00
合作推广
合作推广
分享本页
返回顶部