locked
How to make Dynamic Data Calculated Column as Sortable?? RRS feed

  • Question

  • User1625218257 posted

    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!

    Sunday, December 30, 2012 12:44 PM

Answers

  • User1625218257 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 31, 2012 10:53 AM

All replies

  • User-1716253493 posted
    calculate it in your select command or datatable
    Sunday, December 30, 2012 3:14 PM
  • User3866881 posted

    I've added a Calculated Column to my Dynamic Data site's table.

    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!

    Sunday, December 30, 2012 8:04 PM
  • User-330204900 posted

    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.

    Monday, December 31, 2012 7:17 AM
  • User1625218257 posted

    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.

    Monday, December 31, 2012 10:16 AM
  • User1625218257 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 31, 2012 10:53 AM
  • User3866881 posted

    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.

    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.

    Monday, December 31, 2012 8:22 PM