I've added a Calculated Column to my Dynamic Data site's table. But that field is not sortable by default like the other standard fields are. Is it possible to make a calculated column be sortable by applying a metadata attribute? I've looked and couldn't
find.
To clarify, I don't mean making the table be sorted by default by the calculated column, I mean I want to to be able to sort by it on demand, like the others.
Hi IAmTheWalrus, this does not work in any ORM that I am aware of, as the select command is executed in the DB and therefor is not supported in DD. I get around this but adding a Computed column to my tables in the database this make things simpler and also
means sort and filter works no problem.
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Thanks! But then doesn't that defeat the purpose of DD if you now have to write queries or change you DB to accomodate this tool? Seems to me like a deficiency in DD.
In any event, I'm going to look into perhaps doing this at the gridview level dynamically.
IAmTheWalrus
Member
31 Points
24 Posts
How to make Dynamic Data Calculated Column as Sortable??
Dec 30, 2012 04:44 PM|LINK
I've added a Calculated Column to my Dynamic Data site's table. But that field is not sortable by default like the other standard fields are. Is it possible to make a calculated column be sortable by applying a metadata attribute? I've looked and couldn't find.
To clarify, I don't mean making the table be sorted by default by the calculated column, I mean I want to to be able to sort by it on demand, like the others.
Thanks!
oned_gk
All-Star
31319 Points
6400 Posts
Re: How to make Dynamic Data Calculated Column as Sortable??
Dec 30, 2012 07:14 PM|LINK
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to make Dynamic Data Calculated Column as Sortable??
Dec 31, 2012 12:04 AM|LINK
Hi,
You can just to do this trick at Server ( I mean by SQL statement), something like this:
Select a,b,(a+b) as Total from xxx
And then bind to the GridView with DD.
Reguards!
sjnaughton
All-Star
27308 Points
5458 Posts
MVP
Re: How to make Dynamic Data Calculated Column as Sortable??
Dec 31, 2012 11:17 AM|LINK
Hi IAmTheWalrus, this does not work in any ORM that I am aware of, as the select command is executed in the DB and therefor is not supported in DD. I get around this but adding a Computed column to my tables in the database this make things simpler and also means sort and filter works no problem.
Always seeking an elegant solution.
IAmTheWalrus
Member
31 Points
24 Posts
Re: How to make Dynamic Data Calculated Column as Sortable??
Dec 31, 2012 02:16 PM|LINK
Thanks! But then doesn't that defeat the purpose of DD if you now have to write queries or change you DB to accomodate this tool? Seems to me like a deficiency in DD.
In any event, I'm going to look into perhaps doing this at the gridview level dynamically.
IAmTheWalrus
Member
31 Points
24 Posts
Re: How to make Dynamic Data Calculated Column as Sortable??
Dec 31, 2012 02:53 PM|LINK
I think the answer is here:
http://forums.asp.net/t/1491465.aspx/1
and here:
http://www.mostlydevelopers.com/blog/post/2008/12/07/GridView-Column-Sorting-with-Arrows.aspx (ignore the extra bits about the arrows)
For me this is better than changing the DB schema when I already have the data I need.
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: How to make Dynamic Data Calculated Column as Sortable??
Jan 01, 2013 12:22 AM|LINK
Hi,
It seems that you've found the answer and I'll close the issue by marking it as an answer.
Welcome to your feedback by creating another new issue.