Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to represent an enumeration property via a drop-down box with check boxes

$
0
0

Scenario:

There is an enumeration type decorated with the FlagsAttribute, which means that an enumeration can be treated as a set of flags. There is also a property of this enumeration type inside the business class. This is helpful when several predefined enumeration values can be stored using this data property. In the UI, this data property is usually represented via an editor with multiple check boxes:


Steps To Implement:

Since there is no standard  PropertyEditor for enumerations that would allow you to store several values at once, it is common to implement custom Property Editors for this task. A custom PropertyEditor will take data property value as its input and represent it in the UI using a custom visual control. There will be one PropertyEditor for WinForms (based on the CheckedComboBoxEdit control from the XtraEditors Suite) and one for ASP.NET (based on the ASPxGridLookup control from our ASPxGridView and Editors Suite), because there is no platform-agnostic way to achieve such a look and feel.


Consider following the steps below to implement and use editors from this example in your project.
1. Implement an enumeration type decorated with the FlagsAttribute as shown in the E689.Module\BusinessObjects\DemoObjects.xx file;
2. Copy the E689.Module.Win\Editors\EnumPropertyEditorEx.xx file into YourSolutionName.Module.Win project;
3. Copy the E689.Module.Web\Editors\ASPxEnumPropertyEditorEx.xx file into YourSolutionName.Module.Web project;
4. Build the solution and invoke the Model Editor for the ModelDesignedDiffs.xafml files from YourSolutionName.Module.Win and YourSolutionName.Module.Web projects.

5. Locate the BOModel | YourClassName | Members | YourEnumerationProperty node and set its PropertyEditorType property to the corresponding EnumPropertyEditorEx types.

 

See Also:

Implement Custom Property Editors
How to represent a enumeration property via radio buttons or check boxes on the Web

Question Comments

Added By: Pawel Botwina at: 7/6/2013 1:11:36 AM    

Hello,

How can I filter by flags enum property in the server mode? I mean filtering the ListView by AutoFilterRow.

Added By: Alex Kads at: 4/4/2014 2:35:40 PM    

would that same code for WEB

Added By: Dennis (DevExpress Support) at: 4/8/2014 12:45:41 AM    

@Alex: While we do not have a ready Web version of this example, you may find the code from the E1807 example helpful. Thanks.

Added By: Anatol (DevExpress Support) at: 4/9/2014 9:32:02 AM    

Web version is added.

Added By: Leong Vai Long at: 5/14/2014 3:22:04 AM    

Hi, I had try this method for the XAF web version. The question is how i want to use the XAF Display Name to show in the lookup? bcos I only see the enum values.
Thanks.

Added By: Dennis (DevExpress Support) at: 5/14/2014 9:09:47 AM    

@Leong: This particular functionality is not implemented in this example solution. You would need to modify the E689.Module.Web.Editors.EnumPropertyEditorEx class to achieve this. While we do not have a ready sample, feel free to contact our ASP.NET team on how to implement your task with the ASPxGridLookup component used in this example. Once you receive a solution for this component, it can be easily integrated in XAF.

Added By: Leong Vai Long at: 5/14/2014 10:46:46 PM    

Hi Dennis,

1. Is it possible to change the ASPXGridLookup with the ASPXDropDownEdit? This is the link http://blog.zerosharp.com/three-ways-to-store-a-list-of-currency-codes-in-xaf/#disqus_thread, but this example use the string, how to convert it to enum?
2. How to contact your ASP.NET team to implement my task with the ASPXGridLookup?

Thanks.

Added By: Dennis (DevExpress Support) at: 5/15/2014 7:07:00 AM    

@Leong:

A1: Sure, you are free to implement your own custom PropertyEditor based on any control you want.
A2: You can submit a new question through https://www.devexpress.com/Support/Center/Question/Create and specify the ASP.NET Web Forms platform and ASPxGridView and Editors Suite as a product. In the new ticket describe what you have implemented so far, attach a small non-XAF sample where you tried to customize the ASPxDropDownEdit control and also describe your requirements in detail. Before doing this, you may want to check out the documentation on our ASP.NET Web Forms controls and also corresponding demos. To effectively search our knowledge base, documentation and examples, you may find our Search Engine helpful.

 

Added By: Dennis (DevExpress Support) at: 5/19/2014 6:56:03 AM    

@Leong:

I have modified the Web version of this custom editor to support localized values. Please refer to the attachment.

Added By: MohammedFarooq at: 5/16/2016 7:28:54 AM    Hi Dennis,

How can i read the Text value that is displayed in the editor? Added By: Dennis (DevExpress Support) at: 5/16/2016 7:56:25 AM    

@MohammedFarooq: There are different properties like EditValue/Text/Value in underlying WinForms and ASP.NET controls. Would you please elaborate a bit more on how you are going to reuse these display values (please submit a separate ticket via the https://www.devexpress.com/Support/Center/Question/Create service for that purpose)?


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>