There is a jquery ui sortable widget extension which makes table columns sortable.
According to examples page it is possible to specify row as undruggable.
$(function () {
$('#ex7').sorttable({
placeholder: 'placeholder',
helperCells: ':not(.footerrow td)'
}).disableSelection();
});
I want to set several colspanned rows such way.
But there are several issues occur when i set fixed rows in the middle of the table.
First – fixed rows is not showed as dragged during drag&drop, second – after several movements table becomes broken.
Is there any way to correct it?
UPDATE:
found workaround using absolute positioned div with width=table width, but actually i don’t like it
The problem you are having is that you set the first cell of your static row to a
colspanof 4.When you move that column to the second position the cell with the
colspanis shifted into second position.Now you end up with the second column sontaining the cell with the
colspanof 4 which off-sets everything.I would try and avoid
colspansin cells if you wish to move around columns.You can fix this by simply adding empty cells instead of using a
colspan.Replace this:
with this:
DEMO – v1 – Using individual empty cells instead of colspan
In addition I would probably add some styles to hide the column borders for that row.
Edit
I played around a little longer with this and was able to come up with another alternative. Mind you it is not as smooth as yours and could be seen more
hackyas well.I looked at the
startandstopcallbacks of the sortable extension and wondered if one could add 4 cells atstartand replace them again atstop.When using
startyou will see 4 cells during sorting, which I didn’t like as much as I thought that you want to see the footers during the drag-drop action.The I noticed that when
stopexecutes it executes prior to the actual sorting being applied, makingstartfor our purpose redundant.This means at
stopwe can replace the single cell with 4, let it sort, add a small time-delay usingwindow.setTimeoutwhich then after a small delay replaces the 4 cells again with the 1 cell. That also means the footer stays intact during drag-drop.DEMO – v2 – Using stop to re-draw footers before and after sorting
That seems to work but as I said it is not as smooth as yours as mine is redrawn and causes a little flicker. Also I’m not certain if 100 milliseconds will be enough on the
setTimoutcall when you got a huge table.Either way, I had fun working with this. I hope though this will give you at least some more ideas to play around with.
The code from the DEMO v2