Giter VIP home page Giter VIP logo

table-drag-sort-resize's Introduction

table-drag-sort-resize

Dragging (drag'n'drop), resizing and sorting columns of html tables. Simple and small standalone javascript component.

###Samples

See here for some samples.

###Description

table-drag-sort-resize is a small javascript component which adds basic functionality to html tables: dragging, sorting, resizing. It is completely independent from other javascript libraries but should work side-by-side with any other library like jQuery,etc.

Any html tables which have a thead and tbody tag can be used, e.g.

<table id="example">
    <thead>
        <tr>
            <th>Name</th>
            <th>&Auml;nderungsdatum</th>
            <th>Typ</th>
            <th>Gr&ouml;&szlig;e</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>libraries</td>
            <td>08.10.2013 12:38</td>
            <td>Dateiordner</td>
            <td></td>
        </tr>
        <tr>
            <td>views</td>
            <td>08.10.2013 12:38</td>
            <td>Dateiordner</td>
            <td></td>
        </tr>
        <tr>
            <td>css</td>
            <td>18.05.2014 11:08</td>
            <td>Dateiordner</td>
            <td></td>
        </tr>
        <tr>
            <td>.htaccess</td>
            <td>03.06.2013 14:29</td>
            <td>HTACCESS-Datei</td>
            <td>1 KB</td>
        </tr>
        <tr>
            <td>config.php</td>
            <td>03.06.2013 14:29</td>
            <td>PHP-Datei</td>
            <td>3 KB</td>
        </tr>
        <tr>
            <td>blank.html</td>
            <td>18.05.2014 11:08</td>
            <td>HTLM-Datei</td>
            <td>1 KB</td>
        </tr>
    </tbody>
</table>

#####Supported sorting types

Many different column types can be sorted: numbers, text, web addresses, dates and many more. See Javascript Natural Sort Algorithm With Unicode Support for a detailed description of supported sorting types.

###How to use

In the head section of your html file put

<link href='table-drag-sort-resize.css' rel='stylesheet'>

Just before the end of your body section simply put

<script src='table-drag-sort-resize.min.js'></script>
<script>
  new TableDragSortResize(document.getElementById('example'));
</script>

If you don't want to use default options, pass in an options object as second parameter

  new TableDragSortResize(document.getElementById('example'), {distance: 100, minWidth: 60, restoreState: true, fixed: true});

###Options

  • distance: [type: number] [default: 0] [version: 1.0]

Sets the radius of a circle, where no drag action is triggered as long as mouse movements are within the circle.

  • minWidth: [type: number] [default: 30] [version: 1.0]

Sets the minimum width of the cells.

  • restoreState: [type: boolean] [default: true] [version: 1.0]

localStorage is used to remember the last width of the cells if true.

  • fixed: [type: boolean] [default: false] [version: 1.1]

If fixed is set true resizing a column shrinks or expands the next column. Thus the overall table width doesn't change. In the default behavior (fixed = false) resizing of a column works independently.

###Supported browsers

  • Internet Explorer 8 and newer
  • Opera
  • Chrome
  • Firefox
  • Safari 5.1.7 (and highly possible newer)

###References

This small javascript component uses or is based on other javascript projects and code snippets:

Licence

MIT

table-drag-sort-resize's People

Contributors

ckprod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

table-drag-sort-resize's Issues

Resizing columns in a fixed width table

Let me first congratulate you on your fine achievement in combining 3 key features. Excellent job! The first one I saw around like that.
So, everythign is working just fine, except that I would like to be able to resize columns while keeping the overall table width. Thus a column should gain/lose width to the detriment or benefit of another one.
I have looked at your code, but with lack of documentation, I am not sure what to change.
Could you implement this option?

Thanks,
Jacques

Version 1.1

Thank you for this updated 1.1 version, however, I could not find any updated version in the Javascript library. Can you please double check or point me to the updated table-drag-sort-resize.js file ?

Resizing column when the header is fixed

Hello,

Thank you very much for previous feature. Really great work!
I am trying to have, in pure css, the table header fixed, i.e. that it does not move while the table body scrolls. I have been using a hint I found online to achieve that, which basically is:
table thead tr {
position: relative;
display: block;
}

table tbody {
display: block;
overflow: auto;
width: 100%;
height: 100%;
}

However, when doing so, resizing the column only affects the column in the header.
Can you try it on your side? If you have a workaround / solution, I would very much appreciate it!

Kind regards,
Jacques

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.