In this post, @bradlymathews showed a great idea on how to implement reordable rows on a table component, a much sought feature.
However, i tried implementing this code with the current table but it does not seem to work, since the table component was updated since then.
Can anyone help to refactor the code so that it will work?
This is my current version:
// js_SourceMovePrev
console.log(table2.selectedDataIndex);
if (table2.selectedRow.index > 0) {
console.log('1');
table2.selectRow({mode:'index', indexType: 'data', index: table2.selectedRow.index - 1});
}
// js_SourceMoveNext
if (table2.selectedRow.index < (table2.data.length - 1)) {
console.log('2');table2.selectRow({mode:'index', indexType: 'data', index: table2.selectedRow.index + 1});
}
// js_SourceMoveFirst
if (table2.selectedRow.index > 0 ) {
console.log('3');
table2.selectRow({mode:'index', indexType: 'data', index: 0});
}
// js_SourceMoveLast
if (table2.selectedRow.index < table2.data.length - 1) {
console.log('4');table2.selectRow({mode:'index', indexType: 'data', index: table2.data.length - 1});
}
Source post: Table with reordable rows - #4 by bradlymathews