Definitely we should arrange this new space. Start with a new List Box
Add tree new buttons: UP, DOWN, Save and Close
Change style on List Box to add borders
Rename new elements
Create a new button on the Canvas
Create a script variable
Change name and set as array
Create onClick event for the new - Change Layout button
// Get current dimensions
varcurrentDimensions=Table_Games_Sales.getDimensionsOnRows();
// Assign values to the global variable
ScriptVariable_Dimensions_Values=Table_Games_Sales.getDimensionsOnRows();
// Clear the current list
ListBox_Dimensions_Order.removeAllItems();
// Add current dimensions to the list
for ( vari=0; i<currentDimensions.length; i++ ){
ListBox_Dimensions_Order.addItem(currentDimensions[i]);
}
// Open popup
Popup_Dimensions_Order.open();
Add code for Button_Save_And_close - onClick
// Get all current dimensions
varallDimensions=Table_Games_Sales.getDimensionsOnRows();
// Delete all dimensions
for (vari=0; i<allDimensions.length; i++){
Table_Games_Sales.removeDimension(allDimensions[i]);
}
// Set new dimensions
for (varr=0; r<ScriptVariable_Dimensions_Values.length; r++){
Table_Games_Sales.addDimensionToRows(ScriptVariable_Dimensions_Values[r]);
}
// Close popup
Popup_Dimensions_Order.close();
Add code for Button_Down - onClick
// Get all selected Keys
varselectedValue=ListBox_Dimensions_Order.getSelectedKey();
// Change the order on the list and update List Box
if (selectedValue){
varvalueIndex=ScriptVariable_Dimensions_Values.indexOf(selectedValue);
ScriptVariable_Dimensions_Values.splice(valueIndex,1);
ScriptVariable_Dimensions_Values.splice( valueIndex+1,0, selectedValue );
ListBox_Dimensions_Order.removeAllItems();
for ( vari=0; i<ScriptVariable_Dimensions_Values.length; i++){
ListBox_Dimensions_Order.addItem(ScriptVariable_Dimensions_Values[i]);
}
}
Add code for Button_Up - onClick
// Get all selected Keys
varselectedValue=ListBox_Dimensions_Order.getSelectedKey();
// Change the order on the list and update List Box
if (selectedValue){
varvalueIndex=ScriptVariable_Dimensions_Values.indexOf(selectedValue);
ScriptVariable_Dimensions_Values.splice(valueIndex,1);
ScriptVariable_Dimensions_Values.splice( valueIndex-1,0, selectedValue );
ListBox_Dimensions_Order.removeAllItems();
for ( vari=0; i<ScriptVariable_Dimensions_Values.length; i++){
ListBox_Dimensions_Order.addItem(ScriptVariable_Dimensions_Values[i]);
}
}
At the end we have a complete and working solution. Congratulations š¾ !