OK! Finally got back to working on this. I couldn’t get my button working because it depended on which state I was starting in, and it wasn’t consistent. So, I built a toggle button instead:
var overridesLength = this.parentView.control.overrides.metricSetBindingOverrides.length;
if (overridesLength == 0) //if the overrides don't yet exist, create them with a default state
{
var overrides = JSON.parse("[...AllThatStuffFromTheVideo...]");
this.parentView.control.overrides.metricSetBindingOverrides = [overrides];
table1.loadData();
}
else //if they DO exist, get the current column order and swap the first 2 (what I want for my case)
{
var colOrder = this.parentView.control.overrides.metricSetBindingOverrides[0].requestOverrides.sortPriorityOverrides;
var newFirst = colOrder[1];
colOrder[1] = colOrder[0];
colOrder[0] = newFirst;
this.parentView.control.overrides.metricSetBindingOverrides[0].requestOverrides.sortPriorityOverrides = colOrder;
table1.loadData();
}
Works like a charm. @jeff thank you for the great video to get me 90% of the way there!