Form Splitter In Dynamics 365 for Finance and Operations, complex forms consist of one or more sections. Each section may contain grids, groups, or any other element. In order to maintain section sizes while resizing the form, the sections are normally separated by so-called splitters. Splitters are not special Dynamics 365 for Finance and Operations controls; they are Group controls with their properties modified so that they look like splitters. Most of the multi-section forms in MS Dynamics 365 for Finance and Operations already contain splitters
In this article, in order to demonstrate the usage of splitters, we will modify one of the existing forms that do not have a splitter. We will modify the Account reconciliation form in the Cash and bank management module. You can open this module by navigating to Cash and bank management | Setup | Bank group. From the following screenshot, you can see that it is not possible to control the size of each grid individually and that they are resized automatically using a fixed radio button when resizing the form:
Below we will demonstrate the usage of splitters by improving this situation. We will add a form of splitter between two grids in the mentioned form. This will allow users to define the sizes of both grids in order to ensure that the data is displayed optimally.
- Add the BankGroup form in the AOT and, in the form’s design, add a new Group control right after the ActionPane control with the following properties:
2. Move the DetailsHeader and Tab controls into the newly created group.
3. Change the following properties of the existing DetailsHeader group:
4. Add a new Group control immediately below the Top group with the following properties:
5. Add the following line of code at the bottom of the form’s class declaration: SysFormSplitter_Y formSplitter;
6. Add the following line of code at the bottom of the form’s init() method: formSplitter = new SysFormSplitter_Y(Splitter, Top, element);
7. Save all your code and build the solution.
8. Now, in order to test the results, navigate to Cash and bank management |Setup | Bank groups. Note that, now, the form has a splitter in the middle, which makes the form look better and allows you to resize both grids, as shown in the following screenshot:
How it works…
Normally, a splitter has to be placed between two form groups. In this recipe, to follow this rule, we need to adjust the BankGroup form’s design. The DetailsHeader group and Tab controls are moved to a new group called Top. We do not want this new group to be visible to the user, so we set FrameType to None. Setting AutoDeclaration to Yes allows you to access this object from the code. Finally, we make this group automatically expand in the horizontal direction by setting its Width property to Column width. At this stage, the visual form layout does not change, but now we have the upper group ready.
- We change its Top behavior to Auto and make it fully expandable in the vertical direction. The Height property of the grid inside this group also has to be changed to Column height in order to fill all the vertical space
- In the middle of these two groups, we add a splitter. The splitter is nothing but another group which looks like a splitter. We set its Style property to SplitterVerticalContainer, which makes this control look like a proper form splitter.
- Finally, we have to declare and initialize the SysFormSplitter_Y application class, which does the rest of the tasks.
- In this way, horizontal splitters can be added to any form. Vertical splitters can also be added to forms using a similar approach. For this, we need to use another application class called SysFormSplitter_X.