Giter Site home page Giter Site logo

jebaird / dragtable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akottr/dragtable

62.0 62.0 20.0 128 KB

re-order table columns by using drag'n'drop

Home Page: http://jebaird.com/blog/dragtable-jquery-ui-widget-re-arrange-table-columns-drag-drop

License: MIT License

HTML 66.20% JavaScript 32.68% CSS 1.12%

dragtable's Introduction

jebaird.com

The personal blog of Jesse Baird. All code and content is MIT licensed but remains copyright of Jesse Baird.

Feel free to fork, clone or download this repo to help you get started with jekyll and github pages.

dragtable's People

Contributors

akottr avatar jebaird avatar rosenfeld avatar seb33300 avatar tholman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

dragtable's Issues

Wrong positioning

Hello,

First of all thanks for the plugin, tried a few and right now preferring yours.
I'm with chrome 31.0.1650.63 m and firefox 26.0.
In your code you have a few places that consider scrollLeft property on body (by default) element.
I checked the value of the property.
In firefox always returns 0 (zero) but chrome returns correct value but... when you drag the column it appear positioned properly in firefox not in chrome.
Then in my copy I simply removed all occurrences of scrollLeft and the positioning is fine in all said browsers (including IE 10).

My layout is very simple, the offsetParent for my table is body.

It seems that scrollLeft just unneeded or the calculations that try to take it into account are wrong.

Thank you

Scroll Bars throws it off

When I'm dragging on a table wide enough to cause the page to have a hozitontal scroll bar, the position of the column I'm moving has an offset that does not seem to take the visible window into account, and is not at the same position as the cursor.

I can't provide an example this moment as this is on an internal project server that isn't accessible outside my building, but it should be easy to simulate. If you're unable to recreate this, I can produce an example later on.

Drag column width (while dragging) doesn't retain original column width.

I found that when dragging a column, the drag column (the one displayed while dragging) can appear wider (depending on the content of cells) than the original column, which causes confusion.

To keep the same dimensions I added the code below.

Look for this line of code:
self.dragDisplay = $('<div class="dragtable-drag-wrapper"></div>').append(self.dragDisplay);

Below that, add the following:
var cellWidth = this.element.find("tr:first th:eq(" + index + ")").width();
self.dragDisplay.width(cellWidth);

You may have to change th:eq to td:eq if your table has no th elements.

IE8 compatibility

This plugin seems to not work on IE8.

Do you think it is possible to consider to make it compatible?

Thanks

Support for datagrid sort order labels

I'm guessing that this plugin is used mostly on datagrids, where clicking on column label usually toggles data rows sorting.

Would it be possible to invoke the dragtable functionality only when there's actually drag action, and on regular click to pass event through to the data sorting anchor?

Thanks.

"appendTarget" option should be the table parent by default

When the table is in a "position:relative;" container, draggable columns are not positioned correctly.
This is because the dragged element is added to the <body> by default.
So we have to set the "appendTarget" option each time we use dragtable.
This is a recurring issue since css frameworks like bootstrap set position to relative by default on divs.
Demo: http://jsfiddle.net/cjteLv8v/

RTL Support

When the dir="rtl" for the table, the dragging gives unexpected results.

ie support

currently you can drag one column in ie9, but after that you cant drag an other columns

On drag display gets damaged

Hello Jesse,

I have a table with fixed header, which is achieved using 'display: block', and upon performing the dragging of a column, the column display gets distorted.
I could send you my project for you to have a look at in a pm.

Regards,
Jacques
bug-after
bug-before

Cant set order with Jquery 1.8.1

I don't know if anyone else is having this issue. When I apply 'order' to set the order of the columns, it's giving an error in Firefox console. Find screenshot of the error.
screen shot 2013-06-20 at 2 24 39 pm

Stop event is fired before the dom was cleaned

Hi,
I need to use the stop event to automatically send an ajax request in order to save my table state.
But the stop event seems to be fired before the dom is cleaned.

Can you add a new "finish" event raised when the dom is cleaned?

Thanks

Delay the drag event for 300 ms

Hi,

I implemented "Data Sort" on columns when user clicks on the column header, the function will be broken when i apply the dragtable component. How i could delay the drag event for 300-400 ms, it means if user presses the mouse down and hold it for 300ms, it will activate the drag event, otherwise, it could be consider as a mouse click.

My Best,
Hung Tran

It doesn't work with colspan or rowspan

When I use a table which have any rowspan and colspan cell, I can't drag and drop column properly.
Your library is so cool. It's simple and smooth. I love it. I hope you can fix this issue soon. Thank s.

Why doesnt trigger anchor tags

Hello,

I need some help from you, I added some anchor tags inside the table columns but the problem is that when i click on them, it doesnt trigger the onclick function or href to go to that url. How can i make that possible? Since i think that whatever I click inside the table, it just takes as column click, not an anchor click or whatever.

Thank you.

Best regards,
Ertan Hasani.

tfoot with colspan

I have a tfoot with a colspan and the dragtable is behaving very weird .. the columns go underneath each other and rows are swapping too

Not working woth Sorting

My Smart table has sorting by-default and if I try to implement swapping of cols with this, my table lost sorting as every action on click on col is being taken as Drag/Drop?

Any suggestions :-)

Thanks
Samit

Doesn't distinguish which button is pushed

Either the left or right button causes the drag, effectively disabling a right-click for a context menu. Needs to test MouseEvent.button for zero (assuming using the left button to drag).
Would be nice to have a slight delay before drag engages to ignore click events.

How to make my first 3 <th> static

Hello, how can i make my first three columns static, so someone cant change their order. They have to stay next to each other.

<table id="usersTable" class="table table-responsive table-condensed table-hover">
    <thead>
        <tr>
            <th>Name</th>
            <th>Surname</th>
            <th>Personal Nr</th>
            <th>CIty</th>
            <th>State</th>
            <th>Zip Code</th>
        </tr>
     </thead>
    <tbody>
    </tbody>
</table>

<script>
    $('#usersTable').dragtable({
        scroll: true
    });
    $('#usersTable').on('dragtablestop', function (e, ui) {
        userTableOrder = ui.order;
    });
</script>

What i need right here is that the Name, Surname and Personal Nr should always stay in that order (first, second and third column of the table), and others (City, State, Zip Code) its okay to change the order.

How is that possible?

Thanks in advance.

suggestion for stop event

Hello,

My suggestion is that you fire the Stop event at the very end of _stop method.
In my specific case I was saving the ordering of the columns so I was retrieving it in following way:

var val = [];
$('#mytable th').each(function(){
    val.push($(this).attr('data-header'));
});

That is, taking the columns name from data-header attribute.
I discovered that the column I dragged appears twice, first time at its real position and second time at last position.
This situation kind forces me to understand (I'm not against it though) what is going on inside your plugin...
In my copy I rewrote the _stop method (and I gave up for using return value from event handler as stop event should be just stop event, it is final in some sense):

        $( document )
         .unbind( 'mousemove.' + this.widgetEventPrefix )
         .enableSelection()
         .css( 'cursor', 'move')

        this.dropCol();
        this.dragDisplay.remove()
        this._eventHelper('stop',e,{}); 

Thanks

beforeChange event-handler typo

methinks currently line 479:

if( this._eventHelper('breforechange',{}) === false ){

should read:

if( this._eventHelper('beforeChange',{}) === false ){

thanks for your work and best regards, philip

Drag Column top position out of alignment with table.

I actually thought this was a feature at first but now think it's a bug.

I've fixed this by changing the following line:
elementOffsetTop = self.element.position().top;

To this:
elementOffsetTop = self.element.offset().top;

"position()" calculates the element position relative to the offset parent,
where "offset()" calculates the element position relative to the document.

Drag event overriding click event on column

I have a table that is sortable but when dragging is enabled it overrides the click event for sort. I have tried stopping propagation with no luck. Is there a way to allow the user to click without initiating a drag?

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.