Table with reordable rows

Hi,

Is it possible to make a table and two buttons - up and down that will move the current row in the table accordingly?

Interesting question. The data in the table is an array, so if you change your array order that would do it. perhaps if you used a hidden field/property of the array for your sort, and updated that value across the array with each button press that could reorder it. I can't think of a simple/clean way to do this.

1 Like

Thanks, I have an idea how to do it that way.

I do something similar on one of my apps. I implemented a classic table/subform pattern: I have First/Prev/Next/Last buttons that move the record on a table and then I have a form that shows all of the fields in the selected record. No temp state variables or other plumping needed. This also takes into account if you have any filters applied.

// js_SourceMovePrev
if (tblSource.selectedRow.index > 0) {
	tblSource.selectRow(tblSource.selectedRow.index - 1)
}

// js_SourceMoveNext
if (tblSource.selectedRow.index < (tblSource.displayedData.length - 1)) {
	tblSource.selectRow(tblSource.selectedRow.index + 1)
}

// js_SourceMoveFirst
if (tblSource.selectedRow.index > 0 ) {
	tblSource.selectRow(0)
}

// js_SourceMoveLast
if (tblSource.selectedRow.index <  tblSource.displayedData.length-1 ) {
	tblSource.selectRow(tblSource.displayedData.length-1)
}
1 Like