Wednesday, 12 August 2009

Asp.Net Dynamic Data & Column ordering

As I've mentioned I'm just getting started with dynamic data and uncovering various things that I need to overcome or work around.

The first actual dynamic data issue, rather than linq-to-sql, was limiting the fields that were displayed so I created my class with a MetadataType attribute and I only got the columns that I want to display.

The next challenge was changing the name of a column, again this was easy all I needed in the meta data class was another attribute DisplayName and I could set the name of the column.

The final challenge I faced was needing to reorder the columns since I needed the fields to appear in a different order. So I googled for an attribute I could use to do this and found...nothing.

Out of the box dynamic data, in its current form, does not support re-ordering of columns. To me this seemed such a fundamental thing I was surprised that I couldn't do it.

So I googled some more to see if there were any solutions, custom code, extensions etc that I could find to provide the functionality.

The futures site popped up immediately and that has this functionality plus so much more, only issue is that I wasn't comfortable deploying the futures code for a production system.

So I carried on searching and thats when I found Dynamic Data Columns Ordering, an entry on the MSDN code gallery that contained code that you needed to add to your project and changes to make to existing files and then you just added a ColumnOrder attribute to the meta data and the column appears in the right order.


No comments:

Post a Comment