Today I am going to talk about Adesso Views…how to build ’em, how to manage ’em, how to add filters to ’em, etc etc. What are Views for? A View is the very first thing you see when you open an Adesso application. think of Excel…what you see when you open an Excel spreadsheet is a series of workbooks listed on the bottom of the spreadsheet, and when you click on a worksheet, what you see is usually a huge grid of columns and rows. That’s essentially what an Adesso View is…a listing page that displays all or some of the records in a particular table. With Views, you can narrow your listing to a subset of all the records, you can sort by clicking on the column headers, you can expand and shrink the column headers, you can group subsets of records that share common values for certain fields, you can even display a few basic math functions (minimum, maximum, average, and sum). Bottom line: Views are very versatile in Adesso, and you can have as many as you want.
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.
The columns tab (shown above) displays 2 separate panes:
* 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.
To move fields from the left pane (the available fields) to the right pane, simply click on the Add arrow or All arrow buttons in the middle. If you made a mistake and want to get rid of a field in the view, click on the Del arrow button.
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:
If you select a different table from this dropdown, the list of fields in the left pane will change to display the fields that are inside that particular table. Notice that in the next screenshot, I have selected the Facility table, and also notice that the left pane contains a totally different set of fields.
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.
Now that you understand how to place fields in a view, lets go ahead and do that now. I have labeled this view “by State”. What I mean by this is that in this view, I want to sort the records by US State. That means that at a minimum I should place the field ‘state’ in the view. Ok, I added a few fields to the right pane. Screenshot is displayed below:
Notice that in the right pane, there are some arrow buttons on the bottom. These arrows are used to push fields up or down. The double arrows push a record all the way to the top or all the way to the bottom. To move a field, click on it once and then on the arrow. Pretty basic.
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
Did you notice another small dropdown menu to the right of the arrows? That dropdown gives you the ability to run basic calculations on one or more numeric fields. NOTE: this will only work for integer and float data types. The available functions are:
* 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)
To run more than one of the functions on a given field, click on the dropdown more than once while highlighting the field you want to perform the function on, and continue selecting the functions you want to run. The field displayed in the right pane will refresh and display, in parentheses, what functions will be calculated for it in that view.
Ok, so in this particular view, I want to know the total kilowatts needed by State. How do I do that? First step is to highlight the kw field and select SUM from the bottom dropdown menu. Your screen should look like the following screenshot:
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:
Ok, now we know what we want to display, in what order, and that we want to total the number of kilowatts. Now let’s label the headers for each column. Just to be clear, a header is simply the label above the column of data. By default, the headers for views will use the default label stored from the field designer. When you first started building your application, you probably built your tables first, and when you did, each field that you created had a ‘default label’, where you could assign something other than the fieldname as the default label. The screenshot below illustrates what this looks like from the label designer:
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:
If you want to change the name stored in the column header, just click on the one you want to change, and change it. Self explanatory.
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:
Notice that you can have up to 6 different levels of sorting, the first level being at the top of the window. To explain how this works, imagine having a bunch of records that contain the same value for state, and fewer records that contain the same value for city. For example, lets say you have 100 records, and 50 of them have a value of South Carolina in the state field. Out of those 50, 25 have a value of Charleston in the city field, and 10 have a value of Hilton Head in the city field, and so on. If you sort first by state in ascending order and group the records, and the second sort is set to city in ascending order and group those records too, what you will see in runtime is a header for South Carolina, with all 50 records in there but with two more headers: Charleston and Hilton Head. Under the Charleston header, 25 records will be displayed, while under the Hilton Head header 10 records will display.
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):
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.
There are two event types in an Adesso View:
1. Create a new record
2. Open an existing record
The purpose of events is to allow the application designer to control the behavior of data entry and data record detail display associated with a view. In other words, when a user wants to look at an existing record, he double-clicks on the record in the view. When a user wants to enter a new record, he clicks on the “new Record” menu. What happens next is controlled by these so-called “events”.
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) = “C04”, 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.
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.
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:
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 04m 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.