Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

Microsoft Dynamics AX 2009 : Working with Data in Forms - Creating custom instant search filters

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/4/2012 4:09:08 PM
The majority of data search filters in Dynamics AX are not instant. Normally, the user types in search criteria and then has to press some button or the Enter key in order to execute the search and display the results.

This is acceptable for most people and in most circumstances. But, I have been asked couple of times to enhance the standard search filter to reflect user input instantly upon typing and display filtered data.

In this recipe, to demonstrate how this could be done, we will modify one of the standard Dynamics AX forms. We will change the behavior of the Name filter in the Contacts form in the CRM module to perform instant search upon the user typing.

How to do it...

  1. 1. Open the smmContactPerson form in AOT, and find the CtrlNameFilter control inside the Filter group.

  2. 2. Override its textChange() with the following code:

    public void textChange()
    
    {;
    super();
    this.modified();
    }
    
  3. 3. Edit its modified() method code by changing the following line:

    nameFilter = this.text();
    
  4. to:

    nameFilter = '*'+this.text()+'*';
    
  5. 4. Override the control's enter() with the following code:

    public void enter()
    
    {;
    super();
    this.setSelection(
    strlen(this.text()),
    strlen(this.text()));
    }
    
  6. 5. To test the search, open Basic | Setup | Addresses | Contact Details or CRM | Contact Details and start typing into the Name filter. Notice how the contact list is being filtered:


How it works...

The user typing event triggers the textChange() method on the active control every time a character is typed. So, we have to add search code to this method. However, because filtering is already implemented on this form, we only need to call the control's modified() to start the search. This way we ensure that the search is executed every time a character is typed.

We also modify the control's modified() by adding * to the beginning and the end of the search string. This will make the search by partial string and will not require the user to type in special search characters.

Finally, we have to correct cursor behavior. Currently, once the user types in the first character, the search is executed and the focus is moved by the system out of the control and then moved back selecting all the typed text. If the user continues typing, then the existing text will be overwritten with the new character and the loop continues.

To fix this behavior, we have to override the control's enter(). This method is called every time the control receives a focus whether it was done by a user's mouse, key, or by the system. Here, we call setSelection(). Normally, the purpose of this method is to make a text or a part of it selected. Its first argument specifies the beginning of the selection and second one the end. In this recipe, we are using this method in a slightly different way. We pass the length of the typed text as a first argument, which means the selection starts at the end of the text. And we pass the same value as a second argument, which means that selection ends at the end of the text. It does not make any sense from the selection point of view, but it ensures that the cursor always stays at the end of the typed text allowing the user to continue typing.

The last thing to note here is that system performance might be affected because a data search is executed every time the user types in a character. This is very important when working with large volumes of data.

Other -----------------
- Sharepoint 2007 : Managing Site Security - Set Users’ Permissions on a Site (part 2) - Add Users’ Permissions Directly to or Remove Them from a Site
- Sharepoint 2007 : Managing Site Security - Set Users’ Permissions on a Site (part 1) - Add or Remove Users in a SharePoint Group
- Sharepoint 2007 : Managing Site Security - Get to the Site’s Security Settings Page
- Microsoft Systems Management Server 2003 : Defining and Configuring Site Systems (part 4) - Management Points, Reporting Points & Server Locator Points
- Microsoft Systems Management Server 2003 : Defining and Configuring Site Systems (part 3) - Distribution Points
- Microsoft Systems Management Server 2003 : Defining and Configuring Site Systems (part 2) - Client Access Points
- Microsoft Systems Management Server 2003 : Defining and Configuring Site Systems (part 1) - Site System Connection Accounts & Assigning Site System Roles
- Windows Server 2008 Server Core : Creating Batch Files (part 4) - Using the Prompt Command
- Windows Server 2008 Server Core : Creating Batch Files (part 3) - Using the If Command
- Windows Server 2008 Server Core : Creating Batch Files (part 2) - Using the For Command
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server