Perspective: Any easy way to rearrange order of property array elements?

Is there an easy way to reorder array elements in a component’s properties?

E.g. reordering the columns of a table. I know I can copy the property, paste into notepad, then cut and paste to move around, but this seems like too much hard work for such a simple task. Wondering if there’s an easier way?

image

3 Likes

for your table example you can create a property and have a binding to get the table data as a dataset then use a transform to convert to JSON. if i recall correctly the property elements should be in the same order as your JSON dictionary.

You can actually drag and drop these array elements.

To drag and drop these you can click to the right hand side of the plus icon and move them up and down.

2 Likes

Awesome, I didn’t know you could do this already. I don’t see the plus icon in the version I’m using (8.0.5), however I can still move the elements around by clicking just the right of the end curly brace }. It’s a bit fiddley sometimes, but it works :slight_smile: Thanks
It would be better if the icon was more familiar, like the stacked dashes on their side (mimicking a rubber grip pad with raised nodules), courtesy Google Keep:
image

I’m able to drag properties around as you mention. However, after closing and re-opening the view, the properties are back in the original order. any ideas how to modify this to stay?

The array indices don’t get updated until you deselect/reselect the component (or save the view maybe), but what doesn’t get moved are the bindings that are attached to the objects under the array elements which makes this whole feature useless imnsho… Could this be what you’re seeing instead?

I’ve tried both and still doesn’t seem to work. I don’t want the underlying properties to change, just the order of the properties (to make it consistent with other similar views) Sometimes things get added as an afterthought.

In the video you’re dragging keys of an object. Object key ordering is explicitly non-deterministic - arrays are the only ‘ordered’ json structure.

So then there is no way to change the ordering after the fact?

Correct. Despite object keys not being ordered for any logical/structural purpose, they are saved in a particular order for the sake of minimizing file conflicts between different saved versions of a view.

2 Likes