<scripttype="text/javascript">
//// No Framework
// Set table as sortable
new RowSorter('#table_id'/*, options*/);
// Undo last drag
RowSorter.undo('#table_id');
// Destroy sortable
RowSorter.destroy('#table_id');
//// jQuery Plugin
// Set table as sortable
$('#table_id').rowSorter(/*options*/);
// Undo last drag
$.rowSorter.undo('#table_id');
// Destroy sortable
$.rowSorter.destroy('#table_id');
</script>
Options:
@string handler : drag handler selector (default: null)
@boolean tbody : pass true if want to sort only tbody > tr. (default: true)
@string tableClass : adds this class name to table while rows are sorting (default: "sorting-table")
@string dragClass : dragging row's class name (default: "sorting-row").
@number stickTopRows : count of top sticky rows (default: 0),
@number stickBottomRows : count of bottom sticky rows (default: 0),
@function onDragStart : (default: null)
@function onDragEnd : (default: null)
@function onDrop : (default: null)
Handling Events
onDragStart: function(tbody,row,old_index){// find the table// if options.tbody is true, this param will be tbody element// otherwise it will be table elementvartable=tbody.tagName==="TBODY" ? tbody.parentNode : tbody;// old_index is zero-based index of row in tbody (or table if tbody not exists)console.log(table,row,old_index);},// if new_index === old_index, this function won't be called.onDrop: function(tbody,row,new_index,old_index){// find the table// if options.tbody is true, this param will be tbody element// otherwise it will be table elementvartable=tbody.tagName==="TBODY" ? tbody.parentNode : tbody;// old_index is stored index of row in table/tbody before start the dragging.// new_index is index of row in table/tbody after the row has been dragged.console.log(table,row,new_index,old_index);},// if new_index === old_index, this function will be called.onDragEnd: function(tbody,row,current_index){console.log('Dragging the '+current_index+'. row canceled.');}
I've noticed that for tables that are larger than the window's viewport that the window doesn't scroll while dragging. This can make it difficult to drag an item over a long table. Anyone else run into this and figure out a work around?
Hey !
I have been trying to use the plugins on a 'foreach loop tr ' table without any success.
I just past and glue some example code in smarty tpl file, and that's works well. So the probleme don't belongs into smarty.
Any idea or solution ?
Much thanks in advance
Our team is slowly trying to move away from jQuery, so we'd like to use the non-jQuery approach to new'ing up the object. However, it seems to automatically detect that we have jQuery and force us to use the jQuery approach. Any ideas how we can get around this?
Hello,
I find the onDragEnd event really useful.
I know I can just the download the latest version, but I like getting it versioned through bower.
Can you please make a release with the latest code?
Thank you and happy new year!
Hi, I have a table inside a form, in each row I have a couple of text fields.
When I click the form field inside the table row, it just ignore that I want to write inside... in other words, I'm unable to use a combobox and/or an input box... is there a way to fix this?? please advise.
This might be a minor issue, but wanting to bring this console warning to the attention of the developer for sake of removing any potential bugs it might cause in the future.
RowSorter.min.js:731 Uncaught TypeError: Cannot read property 'tagName' of null
at closest (RowSorter.min.js:731)
at RowSorter._move (RowSorter.min.js:267)
at RowSorter.touchmove (RowSorter.min.js:247)
closest @ RowSorter.min.js:731
RowSorter._move @ RowSorter.min.js:267
touchmove @ RowSorter.min.js:247
Steps to reproduce:
Create a sortable table, with drag handler attached to td.
Drag a table row up/down and move touch pointer beyond the screen edge.
So far in my testing this appears to have no negative effects, in relation to callbacks being fired.
both "onDragStart" and "onDrop" fires successfully.
sometimes there are TD elements in a rows that have other actions - links, buttons, etc.
If you offered a way to exclude those TD cells from the drag and drop it would allow rowsort and still have the ability to interact with links, buttons, etc on certain cells.
I try to open a popver with a click on a button inside a of a rowsorter table. But it doesn't work. Same things for modals and any actions except tooltips.
I have several TD cells with select tags in my table. I also have an input tag in a TD cell. I am unable to change the selected value with rowsorter enabled. Any solution to this?