Hello,
I recently created a JSON table with dropdowns inside of it. It is sorted certain ways with a SQL binding on page launch. When using a system.db.runNamedQuery script to return values based on different filters, I have to finish with this script in order to return it as a JSON object for the table:
returnedData = system.dataset.toPyDataSet(system.db.runNamedQuery(query, params))
NewDict = {'%s' % i:
{colName: value
for colName, value in zip(returnedData.columnNames, list(row))}
for i, row in enumerate(returnedData)}
self.getSibling("Table").props.data = NewDict.values()
I need to figure out how I can sort a table by a certain column in ascending or descending order (extra credit for a sort by another column after the first sort).
So, for example this table is sorted by Hours ascending through a SQL binding returned as JSON..
If I am to select a craft of "Electricians" in my dropdown filter, I get this return...
As you can see, it's sorting by Clock Number ascending. The script for this is as follows with just "sorted" in front of NewDict.values()...
NewDict = {'%s' % i:
{colName: value
for colName, value in zip(returnedData.columnNames, list(row))}
for i, row in enumerate(returnedData)}
self.getSibling("Table").props.data = sorted(NewDict.values())
Thank you in advance for your help.