Forum OpenACS Q&A: Problem with sorting a table.

Collapse
Posted by Nick Carroll on
Hi,

My code does not seem to be re-ordering data in a table when the table header with the sort link is selected.  I'm not sure if my table definition is correctly defined for ordering.  Any help will be much appreciated.

My sql query in my xql file looks like this...

<fullquery name="msg_sql">
  <querytext>
    select id, summary, datefrom messages
    [ad_dimensional_sql $dimensional_list limit limit]
    [ad_order_by_from_sort_spec :orderby :table_def]
  </querytext>
</fullquery>

My table_def looks like this...

set table_def {
    { id "Report" {id $order} {} }
    { summary "Summary" {summary $order} {<td> \
    <a href="summary?[export_vars -url {id}]">$summary</a></td>} c }
    { date "Date" {date $order} {} c }
}

set messages [ad_table -Torderby $orderby msg_sql {} $table_def]

And in the ad_page_contract I have declared the orderby variable as follows...

{ orderby {date} }

I think it is ordering the table based on the date column by default.