Coder Social home page Coder Social logo

zhaoqinghuan / tablednd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from isocra/tablednd

0.0 1.0 0.0 310 KB

jQuery plug-in to drag and drop rows in HTML tables

Home Page: http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

License: Other

JavaScript 44.14% HTML 47.18% PHP 0.59% CSS 8.09%

tablednd's Introduction

TableDnD

npm version CDNJS version jsDelivr Hits Reviewed by Hound

Installation

TableDnD is easy to install:

npm install --save tablednd

or

yarn add tablednd

or

bower install https://github.com/isocra/TableDnD.git

Alternatively you can simply reference from CDNJS:

<script src="https://cdnjs.cloudflare.com/ajax/libs/TableDnD/0.9.1/jquery.tablednd.js" integrity="sha256-d3rtug+Hg1GZPB7Y/yTcRixO/wlI78+2m08tosoRn7A=" crossorigin="anonymous"></script>

or

<script src="https://cdnjs.cloudflare.com/ajax/libs/TableDnD/0.9.1/jquery.tablednd.js" integrity="sha256-d3rtug+Hg1GZPB7Y/yTcRixO/wlI78+2m08tosoRn7A=" crossorigin="anonymous"></script>

You'll also need to include jQuery before you include this plugin (so that jQuery is defined).


Getting Started

Let's create a simple table. The HTML for the table is very straight forward (no Javascript, pure HTML, we haven't added thead or tbody elements, but it works fine with these too):

<table id="table-1" cellspacing="0" cellpadding="2">
    <tr id="1"><td>1</td><td>One</td><td>some text</td></tr>
    <tr id="2"><td>2</td><td>Two</td><td>some text</td></tr>
    <tr id="3"><td>3</td><td>Three</td><td>some text</td></tr>
    <tr id="4"><td>4</td><td>Four</td><td>some text</td></tr>
    <tr id="5"><td>5</td><td>Five</td><td>some text</td></tr>
    <tr id="6"><td>6</td><td>Six</td><td>some text</td></tr>
</table>

To add in the "draggability" all we need to do is add a line to the $(document).ready(...) function as follows:

<script type="text/javascript">
$(document).ready(function() {
    // Initialise the table
    $("#table-1").tableDnD();
});
</script>

Basically we get the table element and call tableDnD. If you try this, you'll see that the rows are now draggable.

In the example above we're not setting any parameters at all so we get the default settings. There are a number of parameters you can set in order to control the look and feel of the table and also to add custom behaviour on drag or on drop. The parameters are specified as a map in the usual way and are described the full documentation:

You can also play and experiment with TableDnD using this jsFiddle. Here you get the documentation, plus live examples.

tablednd's People

Contributors

ajhodges avatar andreyzteel avatar andy128k avatar antriver avatar bacinsky avatar brendon avatar daniel-franz avatar danielboendergaard avatar extend1994 avatar fappels avatar isocra avatar jpgarcia avatar lightdot avatar lukasdrgon avatar megazoll avatar msnider avatar nickl- avatar piotr-przebieracz avatar salbertson avatar shepard avatar tm1000 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.