📜  jQWidgets jqxSortable over Event(1)

📅  最后修改于: 2023-12-03 15:02:21.038000             🧑  作者: Mango

jQWidgets jqxSortable over Event

jQWidgets jqxSortable is a powerful and easy-to-use jQuery plugin that allows you to create sortable lists, grids and trees. One of its key features is the ability to handle various sorting events, which can be very useful in creating responsive and dynamic user interfaces.

Features
  • Easy to use API
  • Ability to handle various sorting events
  • Customizable options for sorting animation and behavior
  • Support for both vertical and horizontal sorting
  • Built-in drag-and-drop functionality
  • Wide range of customizable events
Getting Started

To use jQWidgets jqxSortable, you will first need to include the jQWidgets library and the jqxSortable plugin in your project. You can download both of these from the jQWidgets website.

Once you have these files, you can simply include them in your HTML file:

<!-- Include jQWidgets library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/10.1.5/jqx-all.js"></script>

<!-- Include jqxSortable plugin -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqwidgets/10.1.5/jqxsortable.js"></script>

After including the required files, you can initialize the jqxSortable plugin with the following code:

// Initializing the jqxSortable plugin
$('#mySortable').jqxSortable();

This will create a new instance of the jqxSortable plugin on the element with the ID 'mySortable'.

Handling Events

jQWidgets jqxSortable provides a wide range of events that allow you to respond to various sorting actions. These events can be used to customize the sorting behavior, or to perform additional actions when elements are sorted.

Here is an example of how to handle the 'dragStart' event:

// Handling the dragStart event
$('#mySortable').on('dragStart', function (event) {
    console.log('Dragging started on element ' + event.target.id);
});

This code will log a message to the console when a drag start event is triggered on the '#mySortable' element.

Some of the other events that jQWidgets jqxSortable provides include:

  • sortStart
  • sortEnd
  • dragEnter
  • dragLeave
  • dropTargetEnter
  • dropTargetLeave
  • and more!

For a full list of events and their descriptions, please refer to the jQWidgets jqxSortable documentation.

Customizing Sort Options

jQWidgets jqxSortable provides several options that allow you to customize the sorting behavior and animation. These options can be set when initializing the jqxSortable plugin, or at any time after initialization.

Here is an example of how to set some custom options:

// Setting custom options
$('#mySortable').jqxSortable({
    animationDuration: 500,
    animationEasing: 'easeInOutQuad',
    tolerance: 'intersect',
    dropFeedbackMode: 'fill',
    handle: '.handle'
});

In this code, we set several custom options:

  • animationDuration: The duration of the sorting animation (in milliseconds).
  • animationEasing: The easing function used for the sorting animation.
  • tolerance: The tolerance for sorting elements (can be 'intersect' or 'pointer').
  • dropFeedbackMode: The mode for drop feedback (can be 'fill', 'fit', or 'pointer').
  • handle: The element that will act as the handle for sorting (must contain the dragged element).

For a full list of options and their descriptions, please refer to the jQWidgets jqxSortable documentation.

Conclusion

jQWidgets jqxSortable is a powerful and easy-to-use jQuery plugin that allows you to create sortable lists, grids, and trees. With its customizable sorting events and options, you can easily create responsive and dynamic user interfaces. Its drag-and-drop functionality and wide range of events make it an excellent choice for any web development project.