Perform sort on individual columns in the frontend
Perform sort on individual columns in the frontend
Hi,
after the tutorial on server-side data, I've got it all up and running with a python backend (and the Flask-webframework).
Runs really good so far, thanks, very good work guys!
Now in the backend I sometimes do some post-processing of the columns to add some HTML e.g.:
[code]
for entry in aaData:
# link to customer name
customer = Customer.find_by_name(entry[1])
entry[1] = ('' + customer.name + "")
[/code]
or to aggregate a number:
[code]
for entry in aaData:
# add net value
netvalue = 0
for product in BoughtProduct.get_all_by_orderid(id):
netvalue += product.price
entry.append(netvalue)
[/code]
The numbers are displayed nicely in the table, but how can I perform a sort on the displayed values now, for example on the calculated "netvalues" ? This must happen in the frontend somehow, doesn't it?
Thanks in advance!
Kai
after the tutorial on server-side data, I've got it all up and running with a python backend (and the Flask-webframework).
Runs really good so far, thanks, very good work guys!
Now in the backend I sometimes do some post-processing of the columns to add some HTML e.g.:
[code]
for entry in aaData:
# link to customer name
customer = Customer.find_by_name(entry[1])
entry[1] = ('' + customer.name + "")
[/code]
or to aggregate a number:
[code]
for entry in aaData:
# add net value
netvalue = 0
for product in BoughtProduct.get_all_by_orderid(id):
netvalue += product.price
entry.append(netvalue)
[/code]
The numbers are displayed nicely in the table, but how can I perform a sort on the displayed values now, for example on the calculated "netvalues" ? This must happen in the frontend somehow, doesn't it?
Thanks in advance!
Kai
This discussion has been closed.
Replies
Allan
But this column doesn't exist in the database because its only created in post-processing with:
[code]entry.append(netvalue)[/code]
So I don't want to send an ajax request when I click on this special header, but instead perform an individual search. I know that there is "bSortable: false", which simply turns sorting off for a column, but I need some kind of "bSortableOnDisplayedData: true"
How can I do that?
Allan
Anyway, thanks for the comment, probably I've got to do some more complicated SQL-queries to solve this...