Thursday, April 11, 2013
A platform-agnostic solution to prevent sorting or grouping by a certain ListView column
Today I have refactored one of my examples: http://www.devexpress.com/example=E1254 and want to remind you about it.
View on screencast.com »
Hopefully, you will find the demonstrated solution not only helpful for your project, but you will also recognize the popular pattern of extending the Application Model and try doing the same in your project to accomplish your custom tasks. In short, it is helpful when you want to control certain UI flow or settings at runtime, declaratively and without writing any code from project to project. For instance, once you implemented the model extension in your module, you can specify custom attributes via the Model Editor at both design and run time and then write code that will do something helpful (e.g., disable grid columns sorting and grouping capabilities) based on them.
To get more inspiration, visit the eXpand Framework's site where you can find hundreds of similar extensions for free. To learn more on how to implement such things yourself, study the example's description and code adn then check out the Extend and Customize the Application Model in Code help article.
Some of you (well, let's be honest, many of you:-) ) may ask: why are not these AllowSort or AllowGroup attributes available by default in the framework? Well, imagine that we added them, and then another customer asked for some other cool option. OK, we added it as well and so on. Eventually, will will end-up with a hundred of properties in the application model and the property grid with them will not be usable at all. In addition, the original idea of having generalized and independent from UI and controls abstractions for list and detail form, column, editor will evaporate like smoke. You can find more interesting thoughts on this tough subject at http://community.devexpress.com/blogs/eaf/archive/2006/03/28/applying-styles-to-a-view.aspx (even though this blog post is quite old, the ideas shared in it are still valid nowadays).