jQWidgets jqxScheduler contextMenuItemClick Event

jQWidgets es un marco de JavaScript para crear aplicaciones basadas en web para PC y dispositivos móviles. Es un marco muy potente, optimizado, independiente de la plataforma y ampliamente compatible. El widget jqxScheduler se usa para mostrar un conjunto de citas en un día, una semana, un mes, un día de la línea de tiempo, una semana de la línea de tiempo y vistas mensuales de la línea de tiempo.

El evento contextMenuItemClick se activa cada vez que se hace clic en un elemento del menú contextual del jqxScheduler mostrado.

Sintaxis:

$('#Selector').on('contextMenuItemClick', function (event) { });

Archivos vinculados: descargue https://www.jqwidgets.com/download/ desde el enlace proporcionado. En el archivo HTML, busque los archivos de script en la carpeta descargada.

<link rel=”hoja de estilo” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min .js”></script>
<script type=”text/javascript” src=”jqwidgets/jqx-all.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscheduler.js ”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscheduler.api.js”></script>

Ejemplo: El siguiente ejemplo ilustra el evento jqxScheduler contextMenuItemClick en jQWidgets.

HTML

<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" 
          href="jqwidgets/styles/jqx.base.css" 
          type="text/css" />
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqx-all.js">
    </script>
    <script type="text/javascript" 
            src="jqwidgets/jqxscheduler.js">
    </script>
    <script type="text/javascript"
            src="jqwidgets/jqxscheduler.api.js">
    </script>
</head>
  
<body>
    <center>
        <h1 style="color:green">
            GeeksforGeeks
        </h1>
  
        <h3>jQWidgets jqxScheduler contextMenuItemClick
            event
        </h3>
  
        <div id="jqxs"></div>
        <br>
  
        <div id="log"></div>
    </center>
  
    <script type="text/javascript">
        $(document).ready(function () {
            var onlineClasses = new Array();
            var day1 = {
                i: "1",
                Topic: "C functions",
                schedule: 'room_no. 1',
                begin: new Date(2021, 09, 13, 11),
                final: new Date(2021, 09, 13, 12)
            }
            var day2 = {
                i: "2",
                Topic: "C++",
                schedule: 'room_no. 2',
                begin: new Date(2021, 09, 14, 11),
                final: new Date(2021, 09, 14, 12)
            }
            var day3 = {
                i: "3",
                Topic: "Java",
                schedule: 'room_no. 3',
                begin: new Date(2021, 09, 15, 10),
                final: new Date(2021, 09, 15, 14)
            }
            var day4 = {
                i: "4",
                Topic: "Scala library functions",
                schedule: 'room_no. 1',
                begin: new Date(2021, 09, 16, 11),
                final: new Date(2021, 09, 16, 13)
            }
            var day5 = {
                i: "5",
                Topic: "Test",
                schedule: 'room_no. 3',
                begin: new Date(2021, 09, 17, 10),
                final: new Date(2021, 09, 17, 12)
            }
            onlineClasses.push(day1, day2, day3, day4, day5);
            var src =
            {
                dataType: "array",
                localData: onlineClasses,
                id: 'i'
            };
            $("#jqxs").jqxScheduler({
                source: new $.jqx.dataAdapter(src),
                width: "400px",
                height: "350px",
                date: new $.jqx.date(2021, 10, 13),
                views: [ 'weekView', 'dayView' ],
                contextMenuCreate: function (list, set) {
                    var src = set.source;
                    src.push({ id: "remove", label: "Remove Appointment" });
                    src.push({
                        id: "condition", label: "Set conditions", items:
                            [
                                { label: "Free", id: "red" },
                                { label: "Tentative", id: "orange" },
                            ]
                    });
                },
                contextMenuItemClick: function (list, appointment, event) {
                    var arguments = event.args;
                    switch (arguments.id) {
                        case "remove":
                            $("#jqxs").jqxScheduler(
                                'deleteAppointment', appointment.id
                            );
                            return false;
                        case "red":
                            $("#jqxs").jqxScheduler(
                                'setAppointmentProperty',
                                appointment.id, 'condition', 'red'
                            );
                            return false;
                        case "orange":
                            $("#jqxs").jqxScheduler(
                                'setAppointmentProperty',
                                appointment.id, 'condition', 'orange'
                            );
                            return false;
                    }
                },
                resources:
                {
                    colorScheme: "scheme10",
                    dataField: "schedule",
                    source: new $.jqx.dataAdapter(src)
                },
                appointmentDataFields:
                {
                    id: "i",
                    subject: "Topic",
                    from: "begin",
                    to: "final",
                    resourceId: 'schedule',
                },
  
            });
            $('#jqxs').jqxScheduler('ensureAppointmentVisible', '1');
            $("#jqxs").on("contextMenuItemClick", function (event) {
                $('#log').text("Context menu item is clicked!");
            });
        });
    </script>
</body>
  
</html>

Producción:

jQWidgets jqxScheduler contextMenuItemClick Event

jQWidgets jqxScheduler contextMenuItemClick Event

Referencia: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxscheduler/jquery-scheduler-api.htm

Publicación traducida automáticamente

Artículo escrito por nidhi1352singh y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *