- In the init() method of the form, you need to initialize the listPanel class, specifying, that it is this form you want the list panel to be on, the group that the list panel is going to be in on the form, and any other relevant parameters (for example, when using SysListPanelSet, you usually pass the current state of the values (inSet) as well.
- Most convenient way to accomplish this is by creating a static method with the needed list of parameters, and call this method from the init() method of the form. Usually, this method is named newForm.
- The SysListPanel class contains a lot of parm* methods, that you can use to modify the behavior of the list panel. The SysListPanelSet adds another method to that list, allowing to set the current set of selected values (parmInSet). You can see how these methods are used in Classes\SysListPanelSet_Fields_TableBrowser\newForm() method.
- After basic initialization you have to call the build method. The build method of SysListPanel class is responsible for actually adding all the needed controls to the specified form. Depending on the parameters that you set before calling this method, the list panel will/won’t add the “Add All”/”Remove All” buttons, the “Up” and “Down” buttons, will set the needed number of columns shown in the panels, etc. You can override any of the methods, adding additional functionality (see \Classes\SysListPanelSet_TableBrowser \build() method) or even completely rewrite the code of the basic method (this is not recommended, of course). Notice, that the build method should be called BEFORE super() in the form’s init() method, because FormBuild*Control classes are used to add controls to the form.
- After build method is executed, all FormBuild*Controls are initialized. You need to call the init method then, so that all Form*Control variables are initialized. This method should be called AFTER the super() call in the form init method, as Form*Controls don’t exist until super() is called.
- The last thing you have to do is call the fill method of your new class, so that the list panel is filled with needed data. Let’s talk about this method in a little more detail below.
The Classes\SysListPanel\fill() method, basically, consists of 4 parts:
- getData method is called. This is the method that gathers the data for the left and right part of the list panel. This is an abstract method, and it has to be implemented in the extending class. It returns a container with all the information for the list panel. It is different from class to class and depends on the data being shown in the list panel.
- Both parts of the list panel are cleared and list panel columns are created (the first time).
- fillView method is called for both parts of the list panel. These methods use the data generated in step 1.
- Buttons are enabled depending on the data in both list panel parts. For example, if there are no items selected (left part of the list panel), than the "Remove" and "RemoveAll" buttons are disabled.
The rest of the methods on SysListPanel class are for handling events that occur from user interaction.
The class is the handler of these events in most cases, controlMethodOverloadObject method is used to specify that when the list panel is built.
I guess, the only two methods left that are worth mentioning are the abstract methods addData and removeData. Both of these have to be implemented in the child class, providing the logic for adding and removing items from the left part of the list panel. For example, for SysListPanelSet class the implementation is very simple, just adding or removing the item from the inSet object. For classes extending directly from SysListPanel these methods are where the main logic is located, adding or removing records from the database. In most cases, these methods simply call a server method that does all the needed actions (Remember the rule of thumb – place database logic as close to the database layer as possible).
That is pretty much all you need to know to use and create list panels in Dynamics AX.
Conclusion
Of course, this is not a full description, and much can be added to the information posted here.
If you have any additions, corrections or questions, feel free to post them as comments.
See also
\Forms\Tutorial_SysListPanel
Very helpful post. If you want to start with something simple, then got to Forms/tutorial_ListPanel. This tutorial makes it easy to understand how list panel works.
ReplyDeleteits helpful really , but one question .. how can i raise on select event to handle anything that been selected .. thanx,
ReplyDeleteKhalid Akkawi
Well, here is an example:
ReplyDeleteIf you select 4 items and click the add button (< button), the method
panel_Add_clicked() is automatically called on the SysListPanel class. (I won't go into details as to why this method is called)
in this method, the method SysListPanel.add is called, where the items are iterated one by one. The flag that it uses makes sure that only the selected items are iterated - which is basically what you want, as far as I understand
Well, here is an example:
ReplyDeleteIf you select 4 items and click the add button (< button), the method
panel_Add_clicked() is automatically called on the SysListPanel class. (I won't go into details as to why this method is called)
in this method, the method SysListPanel.add is called, where the items are iterated one by one. The flag that it uses makes sure that only the selected items are iterated - which is basically what you want, as far as I understand
hi can you point out where the data in left selected and right selected views are stored.
ReplyDeletefor example i get some settings from user using list panel then how can i see in the consumer form what settings user chose so that UI can be displayed accordingly ?
I am afraid that's not enough info for me to answer properly, so here's a generic answer:
ReplyDeleteIf you read the post carefully, you saw there are 2 approaches in these classes: 1 where data is stored in the database, and the other is where the data is stored in the inSet variable (of type Set).
The easiest is to just open up an example in AOT (or from the above project) and see how it's done there.
Hi Vanya,
ReplyDeleteThanks for this post. It has really helped to get started. I've implemented a form by creating my own extension of SysListPanelSet.
I have for example a list of customers, so initially I have the list of customers in the left view and the right view is empty.
Now the user selects some users and puts them in the right side. So now I have for example 45 customers in the left side and 5 in the right side.
What I want to do is enable a button in the form, so that I can send a message to the 5 customers in the right side.
However, when I read the "inset" varible, I just get {} with nothing inside.
What is the correct way of reading the contents of the inset variable? or How can I read the data in the right view when the button is clicked?
Thanks
Hey Jack.
ReplyDeleteWould you be able to send me the xpo with your class which I would be able to run on my system?
That would make it easier to understand and answer your question.