Ok here we go… There is a million different ways to do anything as you know… This isn’t the best or fastest or greatest. It just took ten mins tho lol and I’ve never done anything like this…
I think maybe you didn’t see that this column property “field” has to match an object on the props.data… so I start with a dataset like so…

This is handy because as you’ll see. IDK how you’re getting data. But you can supply the data and not have to worry about the order of the columns… that is what the columns property is for… They have to match tho…
So first I set up a custom prop to get the day of the week returned. I don’t want it to poll and keep rerunning my script… so I set it to now(0)… that way it only evaluates on page load…
So now i write a little script to get the names returned… in the correct order. i comment in the script to kind of tell you what i am doing… leave me some slack as im not the best programmer… I wouldn’t run this script in production
Def transform(self, value, quality, timestamp):
"""
Transform the incoming value and return a result.
Arguments:
self: A reference to the component this binding is configured on.
value: The incoming value from the binding or the previous transform.
quality: The quality code of the incoming value.
timestamp: The timestamp of the incoming value as a java.util.Date
"""
# return
##for debug
## if the bound value changes. Script re-runs and builds proper array of column objects
## Sunday is day 1, Saturday is day 7... there might be a python way to do this cleaner..
days = {'Sunday':1,
'Monday':2,
'Tuesday':3,
'Wednesday':4,
'Thursday':5,
'Friday':6,
'Saturday':7}
## dictonaries aren't really meant to be used like this. But this is how you search for a value... we don't need to find first day. But this is how you could..
##firstDay = days.keys()[days.values().index(value)]
## lets make a little thing to give it a start date that is an int 6=friday. so we want the column that is today
## to be the second column so this will make us a list like [5,6,7,1,2,3,4] that we will then use to find the day name later...
daySort = [1,2,3,4,5,6,7]
start = value
tableOrder = []
for i in daySort[int(start-1):]:
tableOrder.append(i)
for i in daySort[:int(start-1)]:
tableOrder.append(i)
## lets make a list of day names...Starting with today and finshing with yesterday...
columnNames = []
for i in tableOrder:
columnNames.append(days.keys()[days.values().index(i)])
## i went to props.columns added a new element and copied it here. this is our base element... im to lazy to change the true & falses to bool(0)
true = bool(1)
false = bool(0)
base = {
"field": "",
"visible": true,
"editable": false,
"render": "auto",
"justify": "auto",
"align": "center",
"resizable": true,
"sortable": true,
"sort": "none",
"viewPath": "",
"viewParams": {},
"boolean": "checkbox",
"number": "value",
"progressBar": {
"max": 100,
"min": 0,
"bar": {
"color": "",
"style": {
"classes": ""
}
},
"track": {
"color": "",
"style": {
"classes": ""
}
},
"value": {
"enabled": true,
"format": "0,0.##",
"justify": "center",
"style": {
"classes": ""
}
}
},
"toggleSwitch": {
"color": {
"selected": "",
"unselected": ""
}
},
"numberFormat": "0,0.##",
"dateFormat": "MM/DD/YYYY",
"width": "",
"strictWidth": false,
"header": {
"title": "",
"justify": "left",
"align": "center",
"style": {
"classes": ""
}
},
"footer": {
"title": "",
"justify": "left",
"align": "center",
"style": {"classes": ""}},"style": {"classes": ""}}
##Ok lets build it out... we know we need to always start with "Line and Shift" so when we build this array of objects( [{obj},{obj}])
##we will always start with this column in the 0th index of the list...
firstCol = base
firstCol['field'] = "Line"
firstCol['header'] = {"title": "Line and Shift","justify": "left","align": "center","style": {"classes": ""}}
columns = []
columns.append(firstCol)
## not that it is in the 0th spot.. lets build the rest of this list..
for i in columnNames:
firstCol = base.copy()
firstCol['field'] = i
firstCol['header'] = {"title": i,"justify": "left","align": "center","style": {"classes": ""}}
columns.append(firstCol)
return columns
So now we have a nice copy of this built columns… I bind props.columns to custom.columnNames…
and viola!
Lets test it by changing my day of the week expression value…So i disable the binding on it… just for a min… then i put in 4… and hey it works… I almost wasn’t expecting it tool lol…