FoxPro Programming
wwHtmlHelpers: HtmlDataGridColumn::SortExpression
Gravatar is a globally recognized avatar based on your email address. wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Kathy
  All
  Jun 19, 2020 @ 11:41am

Hello there,
I was just wondering if we can have a switch between Asc/Desc modes by clicking on the headers of the sortable columns.
Something like this:
Thanks,
Kathy

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Rick Strahl
  Kathy
  Jun 19, 2020 @ 01:05pm

If I recall - headers are clickable to toggle up and down sorting on sortable columns.

No icon though. You maybe simulate something with styling in the sortable CSS class with a background image or by using a custom header expression that customizes the entire header item.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Kathy
  Rick Strahl
  Jun 19, 2020 @ 01:28pm

I'm not sure why the toggle is not working for me!
I have the followings set in my code:

loCol.Sortable=.T.  
loCol.SortExpression = "Value"

Do I need anything more on this?
Thanks.

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Rick Strahl
  Kathy
  Jun 20, 2020 @ 12:51pm

So I checked and columns are sortable but only in one direction. Click the link and it sorts that column and shows a * next to the sorted column.

There's a property that determines ascending or descending via SortOrder but there's no way to toggle. Maybe we can add a SortToggle option and query string that would go back and forth.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Kathy
  Rick Strahl
  Jun 20, 2020 @ 02:19pm

Thank you so much Rick.
Sorry if I should go to the details now but would you suggest adding the SortToggle as a grid property or column property? It looks like SortOrder is one of the grid properties, so would the behavior be natural if I add it to the grid properties?

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Rick Strahl
  Kathy
  Jun 20, 2020 @ 03:56pm

The problem is that there's no easy way to tell if it needs to be toggled. Initial rendering needs to use the default, then subsequent click/render requires to flip the toggle. Right now there's nothing that supports that and no easy way I can think of to generically add the toggle only after the initial sort order was set.

Note you can create custom headers and that might be the better way - in there you can create a custom URL that can switch the order. Note that hte sorting happens on the server, so this isn't ideal anyway. It would be much nicer if sorting could happen on the client without having to refresh the page. But much trickier to do that...

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwHtmlHelpers: HtmlDataGridColumn::SortExpression
  Kathy
  Rick Strahl
  Jun 20, 2020 @ 04:10pm

Thank you so much for the notes.
They're so helpful.
Regards,
Kathy

© 1996-2024