11.05.2015, 18:15 | #1 |
Участник
|
Kashperuk Ivan: Tutorial: Caching display methods
Источник: http://kashperuk.blogspot.com/2015/0...y-methods.html
============== Overview Caching is an important part of the Microsoft Dynamics AX application. It allows us to significantly speed up certain processes by avoiding redundant round trips to the server and the database. Display/Edit methods are a good example of where caching is helpful, as it significantly increases the overall responsiveness of a form. In AX 2012 R3 there are a number of ways you can specify that a display method needs to be cached. Below is a list, as well as a brief description and an xpo with a tutorial form to show the various options.
All cached data methods are calculated and cached in executeQuery of the data source they belong to. That is why it is important to call the above method in the init() of the data source, once the data source is initialized, but the data hasn't been retrieved yet. The optional second parameter controls whether or not the display method value should be refreshed when data is written to DB
Additional info On top of the above, I would also like to mention a few other things.
You can download the xpo project with the tutorial from my OneDrive. Upon opening the form in the project, some data will be pulled into the form. More specifically, the first 3 items/customers/vendors/sites/warehouses. For each of them a display method is present, and one of the above approaches is used to cache it. Step 1 None of the display methods are cached. As you can see, nothing extra was done in executeQuery of the main data source, but itemName was cached for all 3 records for the read-only data source, as the control has "Cache data method" property set to Auto. This happens even though the tab page is not the active one, so it wasn't really yet necessary to calculate these values. Maybe the user won't even navigate to that tab page. You should consider this carefully when designing a form, and always aim at increasing the overall responsiveness of a form by only executing the appropriate display methods. Step 2 and 3 inventSiteName and vendName were cached (through one of the options above). As you can see, now their values are calculated once for each of the records shown. InventLocationName and custName are still not cached. Clicking on Refresh result button will show any extra calls to the display methods since the form started. As you’ll quickly notice, the non-cached methods are being called every time something hints at covering up the value of the control, or rather every time AX thinks it needs to recalculate the value, which is VERY OFTEN. That should make it pretty clear how useful caching is for display methods. Step 4 Now inventLocationName was also cached, and the only method that is remaining and not cached is custName. You can see how more and more methods are executed in one batch on the server as part of the executeQuery method on the data source. Step 5 As the last step, I have added 2 standalone controls that show the Title fields of the main data source table, and started logging the time method caption is invoked. As I have written above, titleFields and parentTitleFields are cached automatically, but you can't really see it, as it is not possible to override it. caption is the closest you can get to it, so I figured it's worth showing that. You can see the method is evaluated right after all data source queries have executed (as it relies on the currently selected record). It is evaluated first time based on the selected data source record, and then again when focus actually goes to the grid, so that the first record is explicitly selected. It will be invoked again whenever the active record changes. Note that unlike custName method, it does not get constantly refreshed. Play around with the form and let me know if you have any questions or comments. Thanks Источник: http://kashperuk.blogspot.com/2015/0...y-methods.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
|
За это сообщение автора поблагодарили: Logger (1). |
11.05.2015, 18:32 | #2 |
Administrator
|
Ваня, большое спасибо за обучалку!
Даже если вещь тривиальная и понятная - то все равно пример использования никогда не бывает лишним. Спасибо за то, что делаешь примеры.
__________________
Возможно сделать все. Вопрос времени |
|
13.05.2015, 11:04 | #3 |
Участник
|
Всегда рад помочь!
|
|
|
За это сообщение автора поблагодарили: sukhanchik (10), Logger (8), Stitch_MS (6). |
29.09.2015, 22:07 | #4 |
Участник
|
а вот как мне обновить TitleDataSource если я переназначил другой источник данных?
__________________
Felix nihil admirari |
|
Теги |
ax2012, display method, полезное |
|
|