Is there a simple “.Net” way to do hierarchical sorting
Table…
A|B|C
-----
1|2|5
2|8|4
2|4|3
3|7|2
4|4|1
clicking on A, then B would get you..
A|B|C
-----
1|2|5
2|4|3
2|8|4
3|7|2
4|4|1
The change being that I’m sorting (B) in context of (A) and so forth.
Obviously this could be managed in the datasource, but was wondering if someone has a elegant and scalable solution.. thanks.
If you’re asking about doing it in conjunction with paging, there’s no simple and scalable solution. In fact, that is kind of a holy grail of business application web development. See, for example, the StackOverflow question Dynamic Sorting within SQL Stored Procedures, which concerns the same thing. After all, if we had dynamic sorting on our database servers, we would only have to code the mechanism for managing the user’s sort choices.
You really only have three options for multi-column sorts:
Do it in the client, letting your data container do the heavy lifting (when you’re using a data container that has this functionality built in, like
System.Data.DataView).Write your own algorithm and sort the data yourself before binding.
Do it at the database server via one of the solutions discussed in the link above.
Neither of the client-side solutions are really scalable since they involve pulling and delivering all your data when you may only need a subset.