Move item in table up and down

I have createt a table where i can insert data to but i also need button to move the select up or down, i have tried some code but cannot get it to work???

Hi Miol
You can add an attribute to a table parameter (provided it is backed by an INT16/INT32 and not an INT16_ARRAY/INT32_ARRAY) to provide a drag-to-reorder handle. If you would also like up/down buttons, you can use the example posted below to see how to shuffle the parameter values around:

value_param a b c d e f g function moveUp() { move(-1); }

function moveDown()
{
move(1);
}

function move(direction)
{
var selection = params.getValue(‘params.table’, 0);
var newSelection = selection + direction;

if (newSelection < 0 || newSelection > params.getElementCount(‘value_param’))
{
return; //If we are moving up but are already at the top or moving down and are already at the bottom
}

var newValues = ;
var oldValues = params.getAllValues(‘value_param’);

for (var i = 0; i < oldValues.length; i++)
{
if (direction > 0 && i != selection) //If we are down, add the value already at index first
{
newValues.push(oldValues[i]);
}

if (i == newSelection)
{
newValues.push(oldValues[selection]);
}

if (direction < 0 && i != selection) //If we are up, add the value already at index after
{
newValues.push(oldValues[i]);
}
}

params.setAllValues(‘value_param’, newValues);
params.setValue(‘params.table’, 0, newSelection);
}

true moveUp(); moveDown(); [#DashBoard](https://livinglive.community/search?s=tags%3A%22DashBoard%22&executesearch=true)