AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск Все разделы прочитаны

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.07.2016, 20:11   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
dynamicsaxhints: How to add enum filter with All element
Источник: http://dynamicsaxhints.blogspot.com/...l-element.html
==============

Sometimes customers request a specific filter in a form. The filter is based on an enum and must have All element to display all records regardless of field value. For example, a filter has 3 elements: All, Quotation, Order; although enum has only 2 elements: Quotation, Order.

Problem description
Analyse how All element is added to an enum filter in standard AX.

Hints
To answer the question let's search for enums with All element and Filter suffix in standard AX.
Solution
There are mainly 2 approaches in standard AX:
- create duplicate enum with Filter suffix and additional All element
- create filter control in code.

Approach 1. Duplicate enum and add All element
Less code is needed to implement a filter, but more maintenance work is required when an enum is extended or changed. There are several examples in standard AX.

PayrollPeriodStatus and PayrollPeriodStatusFilter enums:
Note: elements of PayrollPeriodStatusFilter enum have different labels from PayrollPeriodStatus enum. It is user friendly, for example in PayrollCalculationFrequency form:

WrkCtrType and WrkCtrTypeFilter enums:
All element has no label, but the functional meaning behind it is the same. For example, in WrkCtrResourceAbilityMap form all Resource type are displayed when an empty element is selected in the filter:

Approach 2. Build ComboBox control in code
The algorithm is the following:
- an unbounded combobox control is added to a form
- All element and required base enum elements are added to the control during form initialisation
- internal map is used to store a relation between control elements and base enum elements.

An example in standard AX is StatusFilter control in WorkflowStatus form:
All element and base enum elements are added to the control in \Classes\WorkflowStatusForm\setRangeFilter method:
Note: In this case a map to store a relation between control and enum values is not created. It is not an optimal solution, because enum values can be out of range 0..(number of elements - 1) and the following code in WorkflowStatusForm.setStatzsFilter method may fail (marked in red):

There is another example in standard AX where a map is created:

Approach 3. Blank element
Based on the examples in standard AX I want to suggest an alternative solution - add the first enum element named Blank and without a label:
Use the enum as a filter in form. When Blank element is selected - all records are displayed, when another element is selected - specific range is applied.

Conclusion
Any of the mentioned approaches can be used to add enum filter with All element. It is more about a matter of taste.

Источник: http://dynamicsaxhints.blogspot.com/...l-element.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
dynamicsaxhints: How to make enum a mandatory field on a table Blog bot DAX Blogs 0 04.05.2016 06:17
Navigate Into Success: Deploying control add-ins during development in NAV 2016 Blog bot Dynamics CRM: Blogs 0 13.11.2015 10:00
atinkerersnotebook: Using the Dynamics AX Excel Add-In Blog bot DAX Blogs 1 25.09.2013 07:11
atinkerersnotebook: Walkthrough & Tutorial Summary Blog bot DAX Blogs 1 09.09.2013 09:11
NAV reporting: How to add a Company Picture to a Report Blog bot Dynamics CRM: Blogs 0 05.02.2009 23:50
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 13:04.