This Chapter 10 , if you want to start from the beginning you find it here and the previous chapter
Here is the video: https://youtu.be/2K5YHBVyhyA
Video 10 : MDriven Education Video Chapter 10 : Creating a report
Title | Content | Time(segment start) |
Introduction | Introduction | 00:00 |
Fixing errors | Handling errors, locating them and fixing them | 00:06 |
LinkRoleName | Link classes, changing LinkRoleName and fixing the errors the change creates. | 05:52 |
New viewmodel | Creating a new viewmodel | 16:22 |
Creating a report | Creating a report, creating the template URl | 23:07 |
Adding data | Creating a report, adding data to the report document | 34:13 |
Correct errors if you have them, set Link Role names on Association classes, Create open-document reports
302 Create some intentional errors for example by renaming the CartransferOwnershipDocuments to CartransferOwnershipDocument - save and practice to follow the error leads from the red dots - and fix the error.
303 Create some intentional errors for example by changing the expression of a class action on Car - save and practice to find the error from red dot - fix the errors - save - ensure clean model with no errors.
304 Find the link class HistoricOwnership - select the association and change from <Default> to HistoricOwnerships (with a plural s) in the LinkRoleName on both Association ends for the associations. Save - see the errors.
305 Fix the error by clicking them up - and update the expressions to reflect the new name HistoricOwnership -> HistoricOwnerships
306 Drop the ShowCar action that does not have a ViewModel to show
307 Create a New ViewModel called ProperCarView, set the Class to Car, Set Requires Root.
308 Add a Class Action to bring the ProperCarView up
309 Show the RegistrationNumber in the PropertCarView by adding a column
310 Add also the State, BrandOfCar, CarOwner - make them static to avoid edit
311 Add the Multilink for CarTranserOwnershipDocuments as grid
312 Add columns in this grid, Seller, Buyer, remove the AsString default column
313 Start the web prototyper , search cars - open the PropertCarView on a Car that has CarTranserOwnershipDocuments
314 Add a Class action - ProduceDocument , give the ExecuteExpression the value of self.opendocumentreportshow(CarTransferOwnershipDocument.ViewModels.TheTemplateForCarTransferOwnershipDocumentReport) - expect the error due to not having the TheTemplateForCarTransferOwnershipDocumentReport viewmodel yet
315 Create a TheTemplateForCarTransferOwnershipDocumentReport viewmodel, set class to CarTransferOwnershipDocument, check the Requiers Root box
316 Right click menu in the ViewModel tree - Add columns needed for report, expect the TemplateUrl and ReportFileName viewmodelcolumns
317 Verify that the action that was faulty before now finds the TheTemplateForCarTransferOwnershipDocumentReport
318 In the TheTemplateForCarTransferOwnershipDocumentReport - viewmodel - click out the UsePlacingHints to hide the UI part of the ViewModel
319 In the FileMenu ShowCurrentModelDirectory, check the model file name - "Start.modlr" , create a folder Start_AssetsTK - read about on AssetsTK on the wiki
320 Create a folder Content in Start_AssetsTK, start word , new document , write "this will be my template" save as ODT format in Start_AssetsTK/Content - call the file ThisWillBeMyTemplate.odt
321 Close word - in order to avoid file loch while MDrivenDesigner tries to access it
322 check that your appurl starting with http://localhost:... , test http://localhost:<port>/content/ThisWillBeMyTemplate.odt - ensure that you can access the template (you must use the port number you use)
323 In ViewModel for the template in the TemplateUrl set the string value 'http://localhost:<port>/content/ThisWillBeMyTemplate.odt'
324 Set the ReportFileName expression to 'TheSalesReportForCar'+self.Car.RegistrationNumber+'.odt'
325 Test the ProduceDocument action - ensure that you get a document - with name from the registration number
326 In the template odt add %meta% - save and close - resave the model to upload - Test the ProduceDocument again - verify you see the expanded proprties from the %meta% tag
327 Head back to viewmodel for template and add Buyer, Seller,RegistrationNumber and Brand (self.Car.Brand.Name)
328 Test the ProduceDocument action again - copy the expanded viewmodel data names from the document - paste those into the original document - this will be expanded to data
329 Write a text in the template and mix in the tags: The buyer named %Buyer% has purchased the car %RegistrationNumber% of type %Brand% from %Seller%
330 Turn off spellcheck in document so that tags does not distorted in the resulting file, save , close word , save model
331 Test the ProduceDocument action again - ensure you get a document with tags expanded to data according to the definition in your template viewmodel