For teaching this topic of Views, I am going to use an application we built for the US Army Corps of Engineers as a demonstration on how our software could be utilized to conduct power assessments using Adesso. This database was built to showcase how Adesso could be used to replace paper forms with a digital system capable of capturing kilowatt, voltage, and other data for life sustaining facilities so that the Army 249th Battalion, whose mission is emergency generators, could supply the proper emergency generators to facilities if a natural or man-made disaster occurred. Its a bit more complex than just going to Home Depot to pick up any 'ol generator and getting UPS to deliver it! Anyway, lets get started on Views.
Adesso Views Designer
The Views designer in Adesso is used to create grid views that look sort of like what an Excel spreadsheet looks like: a bunch of columns and rows of data. An Adesso view behaves like Excel in many instances, but Adesso is a database engine, not a spreadsheet, so it can do a lot of things that Excel can't do, but it also can't do a lot of things that Excel can do (like complex mathematical calculations, cut and pasting from cell to cell, etc). The views designer screen is illustrated below:
Whenever you create a new view, it will appear in the right pane in the image above. If you want to sort the list, click on either the Name or Data Source header and it will sort the list by that column. To create a new view, click on the 'New' button on the bottom of the Views designer window. Once you do that, a new window will appear on your computer that will look like the following:
You will be prompted to give your view a name. What should you call your view? Whatever you want. I tend to name my views by the name of the main sorting function in that particular view. In other words, if I create a view and set it so that that particular view, when first opened, sorts by column X, then I would name that view "by Column X". By doing it this way, my users already know by just looking at the view that the records in that view will be sorted by Column X. Easy as pie to understand.
The only other option in the screen above is the data source you will use for your view. Data source is just another big term for table. When you click on the data source dropdown menu, all the tables you have created in your application will be available as a data source. Simply pick one from the dropdown, name your view, and click on ok. (You can change the view name later, so don't get paranoid about getting the name just right).
Once you select a data source and a name, and click on the ok button, you will see the following window:
Notice that there are several tabs across the top of the window. When you first create or open a view, the first tab to be displayed is the Columns tab.
Columns Tab
- The left pane lists all the fields available to you to insert into the view.
- The right pane lists all the fields currently in the view.
Now notice that there's a dropdown menu on the bottom left of the screen. That particular dropdown menu will list tables that are available to the view because a relationship has been established between the table being used as a data source for the current view and the table in the dropdown list. If you click on the dropdown, it will look something like this:
Notice that the left pane now displays fields but now each fieldname also is followed by a the relationship name inside parentheses. For example, the field mission_no is represented by mission_no(Facility(Assessment-Facility)). The reason it is listed this way is to give you a visual cue that that particular field is not a field that is contained inside the data source table that you are using for this particular view. Rather, it is a field that can be made available to the view because of an established relationship between the data source table and the table that that particular field belongs to. Simple as that.
In an Adesso view, as in Excel, fields are displayed in columns from left to right. In the view designer, the topmost column will display as the leftmost column in runtime mode, and the bottommost column will display as the rightmost column in runtime.
Min, Max, Average, and SUM Functions
- MIN (this will provide the minimum value for the selected field(s) in the entire recordset displayed, including group headers)
MAX (this will provide the maximum value for the selected field(s) in the entire recordset displayed, including group headers)- AVG (this will provide the average value for the selected field(s) in the entire recordset displayed, including group headers)
- SUM (this will provide the sum total in the entire recordset displayed for the selected field(s), including group headers)
Notice that the field kw is now displayed as kw(SUM). This denotes that this field will be summed, with the total sum displayed at the bottom of each grouping and the bottom of the entire recordset.
But wait! Do you really want to have the City and State all the way to the right hand side of the grid in runtime? Probably not, especially if we are going to sort the view by State. So let's move the city and state fields toward the top of the right pane, just below mission_no. Now our screen looks like this:
Headers Tab
Ok, now back to the Headers tab. When you click on the Headers tab, your screen will look like this:
The column header column (on the far left) is essentially the label that will be used to display the name of the column in runtime mode. The fieldname is just that...the field that will be used for populating the column. The miniview column width displays the number of pixels wide that the column will default to when you create a miniview (which is different from a regular view...more about this when we talk about Forms). By default, the number of pixels is 80. The alignment column determines whether the values in that column will be left justified, center justified, or right justified. By default, text and date fields are left justified, numeric fields are right justified, and yes/no fields are centered. However, you can simply click on the alignment column for a specific field and change the alignment by selecting a value (Right, Left, Center) from the dropdown. When you click it, it will look like the following screen:
Sort Tab
The Sort tab is one of the more powerful pieces of the View designer. From here, you will be able to assign a way to sort and group your records. When you click on this tab, your screen will look the following:
I have decided that for this view, I want to do what I said above, but also add one more level of sort, by facility name. My screen looks likes this:
In runtime, my screen will look like this:
Notice that because I told the view to group first by State, and THEN by city, you have a series of collapsible/cascading headers, each one expandable/collapsible by clicking on the + or - sign to the left of its name. You can also expand or collapse headers all at once at different levels by clicking on the expand or collapse icons in the icon toolbar.
Finally, you should also notice that KW is now totaled at the bottom of each group, at each group level (denoted as TOT on the far left of each total row). That's because we assigned the SUM function to that field earlier in this tutorial.
Let's get back to the Sort tab. Notice that at the bottom of the sort tab, there is an Appearance section that lets you default the view (if you are using groups in the view) to either display all the records or not display them, and to either display the record count in the header or not display the record count. The way this works is that if you tell it to display the group expanded, then when the user, in runtime, clicks open the view, by default the records will be completely collapsed, and the user will need to pop the headers open using the icons or by manually clicking on each header. Let me show you what this looks like in runtime:
If you click on the expand icon once, your screen will refresh and look like this:
Finally, notice that there is a number in parentheses to the right of each header. This is the record count. If you want to hide this record count, all you need to do is click on the checkbox called "Hide record count in group headers". This checkbox is listed at the bottom of the sort tab (screenshot is displayed below):
Print Tab
Unfortunately, there's not much in the print tab to work with. This part of Adesso is admittedly weak, and we need to improve this. Plans are to build a much-improved print feature in the next major release, Adesso v5 (we are currently on v4.1.3). But for now, it's merely a way to create simple print output formats for record listings. Printing detail forms is not supported currently...only grid view/record listings.
Events
There are two event types in an Adesso View:
- Create a new record
- Open an existing record
When you click on the Events tab, you will see the following screen:
Notice that there are two main functions on this screen: 1) New Record; and 2) Open Record. you will also notice that for each of these event types, there are two separate options: 1) Navigate to form; and 2) Call Plug-In.
By default, when you create a view, it will automatically use the default form for both types of events. However, if you create multiple forms for a particular table, you can select a specific form from the dropdown menu for either event or both events. Let's say you want to hide some fields if a user is going to open an existing record, but you want the user to see a completely different form with more fields in it if he is creating a new record. You can select a particular form for new record events and a completely different form for opening records. To select from a listing of available forms, simply click on the dropdown box.
If you only have one form, the dropdown will only contain that one form plus a conditional statement. If there are more forms available for that table, they will all show up there, plus the conditional statement.
Let me show you what the dropdown menu looks like when you have created more than one form for a table. In this new example app, we have built several forms for the same table. Notice that they all appear in the dropdown, in addition to that conditional statement:
To select a form, simply select it from the dropdown.
Conditional Form Selection
You can use the conditional statement to select one form or another based upon an expression, or condition in the record. We will use the application in the example above. When I click on conditional, the expression editor will appear, like the screenshot below:
You can create extremely complicated expressions, but its not too difficult and shouldn't scare you. The complicated expression that I am using for this particular conditional statement is a series of nested IF statements. The entire expressions is listed below:
IF(LEFT(Inspection_ID, 3) = "C01", GUIDOF([Forms!DiscrepancyCIP1]), IF(LEFT(Inspection_ID, 3) = "C02", GUIDOF([Forms!DiscrepancyCIP2]), IF(LEFT(Inspection_ID, 3) = "C03", GUIDOF([Forms!DiscrepancyCIP3]), IF(LEFT(Inspection_ID, 3) = "C04", GUIDOF([Forms!DiscrepancyCIP4]), IF(LEFT(Inspection_ID, 3) = "C05", GUIDOF([Forms!DiscrepancyCIP5]), IF(LEFT(Inspection_ID, 3) = "C06", GUIDOF([Forms!DiscrepancyCIP6]), IF(LEFT(Inspection_ID, 3) = "C07", GUIDOF([Forms!DiscrepancyCIP7]), IF(LEFT(Inspection_ID, 3) = "C08", GUIDOF([Forms!DiscrepancyCIP8]), IF(LEFT(Inspection_ID, 3) = "C09", GUIDOF([Forms!DiscrepancyCIP9]), IF(LEFT(Inspection_ID, 3) = "C10", GUIDOF([Forms!DiscrepancyCIP10]), IF(LEFT(Inspection_ID, 3) = "C11", GUIDOF([Forms!DiscrepancyCIP11]), IF(LEFT(Inspection_ID, 3) = "C12", GUIDOF([Forms!DiscrepancyCIP12]), IF(LEFT(Inspection_ID, 3) = "C13", GUIDOF([Forms!DiscrepancyCIP13]), "")))))))))))))
Notice the pattern here: IF the first 3 characters in the field Inspection_id = "something of importance", then use the form labeled "DiscrepancyCIP1", ELSE, IF the first 3 characters in the field .... and so on and so on.
The syntax for forms is GUIDOF([Forms!FormName])
To simplify things, think of it this way:
IF(field_x) = "value you are looking for", GUIDOF([Forms!FormX]), GUIDOF([Forms!FormY]))
So, if field_x contains a specific value you are looking for, use FormX to display to the user when he creates a new record from that particular view, otherwise, use FormY to display. Make sure your brackets and parentheses are correct.
I hope this makes sense.
Run Plug-In Event from a View
You can also run a plug-in event from a View. That's what the checkbox is there for in the Events tab. This feature is usually used to call an input form created in .NET, where you can build it to look however you want it to look like with no restrictions whatsoever imposed on you. Let me show you one of those:
Notice that in this example view, instead of selecting a particular view created in Adesso, we are selecting a plug-in labeled PickupForm for both types of events. Discussion of plug-ins is beyond the scope of this particular blog post (I will talk more about plug-ins in a separate blog post). Although we are triggering the plug-in by itself, notice that you can trigger the plug-in AND select an Adesso form at the same time. In our particular case, we only want to pop open our own customized form. In runtime, when the user creates a new record from this view, it will run the plug-in, and this particular plug-in opens an input form of our own, as illustrated below:
What we wanted to do was create a form with 2 giant buttons only (along with a big cancel button). While you could do this in an Adesso form, there are some functions running in the background when the user clicks on either button that cannot be done in a native Adesso form. So we chose to build a plug-in in .NET to create a very specific form.
NOTE: if you use your own forms via the plug-in architecture, you need to know that you will need to create your own validation controls in .NET. In a native Adesso form, you can create validation controls pretty easily, but they won't be available for custom forms...you will have to do this manually.
Appearance Tab
The appearance tab allows you to select a theme for the coloring of the rows, headers, fonts, etc. Themes have their own designer from the main Application Designer screen. Build a theme from there, and it will be made available in the dropdown menu from the themes tab.
Other Tab
The most important part of the Other tab is the ability to assign filters to the view. A filter can be created from the Filters Designer screen that is available at the main page of the Application Designer (see screenshot above).
When you first click on the Other Tab, it will look like this:
Filters
When you create a filter, it will be available from both the required and default filter dropdown menus. You have to build the filters first before seeing them in the dropdown. Once you build them, you can then select them. We will discuss filters in detail on a separate blog post.
Notice that in the filters section of this tab, there is a required view filter and a default view filter. A required filter is just that: the view will ALWAYS use that filter, and won't let the user de-select the filter. The default filter means that the view, when first opened by the user, will use that particular filter as a default, but the user can take the filter off or change it to a different one.
The freeze first XX columns is similar to Excel's freeze vertical pane feature. You could freeze the first column, and when you scroll to the right, that column will always appear in the list.
The display XX lines per row defaults to a value of 1 but can be changed here.
The do not include this view in the list view checkbox, if checked, means that users in runtime won't even know that that view even exists. You may want to build invisible views that you use for 02m controls within forms, and for import and export templates that you don't want your users to see in runtime.
Disable statistics means that no record counts will be displayed in headers, etc
Automatically recalculate expressions on open means that when a user pops open a record, all the expressions in that table will recalc.
No comments:
Post a Comment