Product Sorting

I'm working on Browse.aspx from the starter site and I want to implement sorting functionality based on the column header in the GridView.

I know the productList control uses the ProductFilterDataSource control to get it's data and ProductFilterDataSource inherits from CatalogDataSource.

I think I've done everything correctly, but the error I keep getting is "The data source does not support sorting."

Anyone have any ideas or guidelines I should be following to get this working?

Thanks,
Brad

[577 byte] By [takobell] at [2008-3-3]
# 1
I can get sorting to work if I set "AllowSorting" to true on the GridView in ProductList.ascx. I then set the SortSexpression in the various TemplateFields to the appropriate value (such as "cy_list_price" for the price column). One problem that shows up is that clicking on the header again appends "DESC" to the sort expression which isn't appreciated by Commerce Server search. I don't have a solution to this (I'll work one out) but I would imagine it involve either handling the OnSorting event to adjust the srot expression or stripping the DESC out of the sort expression in CatalogDataSource.
JoeWasson-MSFT at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2
Hi Joe,

Thanks for the input. I had gotten that far and was attempting to handle the onsorting event to get bi-directional sorting working. That's actually when I got the error I originally posted about.

I'd love to see your solution to the problem.

Regards,
Brad

takobell at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 3

Anyone found a solution to bidirectional sorting ?

i keep getting this error when i try to reverse sort

'Invalid column name 'DisplayName DESC'.

Best regards

Philip Haugaard

PhilipHaugaard at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 4

It may not be the most efficient way, but I passed the sortexpression into a function that parses it out and does a catalog search for products and sets the SortDescending property of the searchOptions to a boolean based on whether DESC is found in the sortParams string. The searchOptions class also supports paging parameters that translate pretty closely to the ObjectDataSource paging params (startRowIndex, maximumRows) , which is why I went with this method.

Take a look at the CatalogSearch and SearchOptions classes in the Class Reference for more info.

Hope that helps,

Dave

DMAR330 at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 5

Try specifying the sort property as [DisplayName]DESC

VinayakTadas-MSFT at 2007-9-4 > top of Msdn Tech,Commerce Server,Commerce Server 2007...