Difference between revisions of "Introduction to SubTables"
Line 1: | Line 1: | ||
A [[SubTable]] provides an edit table view for the users of your model, but which displays only a subset of a larger edit table, and may display the rows or columns in a different order from the original. In this mini-tutorial, you'll create a [[SubTable]] view. | A [[SubTable]] provides an edit table view for the users of your model, but which displays only a subset of a larger edit table, and may display the rows or columns in a different order from the original. In this mini-tutorial, you'll create a [[SubTable]] view. | ||
+ | = Preliminaries = | ||
Begin by downloading the following model as a starting point: [[media:California Power Plants2.ANA]] | Begin by downloading the following model as a starting point: [[media:California Power Plants2.ANA]] | ||
Line 12: | Line 13: | ||
A user can edit this large table, but you may have certain users that need to worry only about Natural Gas plants. For these users, we can provide a [[SubTable]] containing only the rows corresponding to Natural Gas plants. We can also sort the table for them, and eliminate the ''Plant Type'' column, since it will always beset to Natural Gas. | A user can edit this large table, but you may have certain users that need to worry only about Natural Gas plants. For these users, we can provide a [[SubTable]] containing only the rows corresponding to Natural Gas plants. We can also sort the table for them, and eliminate the ''Plant Type'' column, since it will always beset to Natural Gas. | ||
+ | |||
+ | = Defining the [[SubTable]] = | ||
Steps: | Steps: | ||
Line 53: | Line 56: | ||
[[image:Subtable Edit View.jpg]] | [[image:Subtable Edit View.jpg]] | ||
+ | |||
+ | = Trying it out = | ||
+ | |||
+ | 9. In the edit table for ''Gas Plant Data'', change the MegaWatts value for 'UCSD' to 2.83K. Press the green check to accept the change. | ||
+ | |||
+ | 10. Examine the original (large) edit table for ''Power Plant Data''. Find the 'UCSD' entry, which should be the top row. Notice that the value in the master table has changed. | ||
+ | |||
+ | 11. Try changing other values in each table, pressing the green check in the table where the change is made each time, and watch how the corresponding value changes in the master- or sub-table. | ||
+ | |||
+ | 12. Temporarily enter edit mode so that you can change ''Sort By''. Select MetaWatts, for example, and note how the rows of the SubTable change their order. (You may want to switch back to browse mode). | ||
+ | |||
+ | 13. In the Subtable, while Sort_By='MegaWatts', change values in the MegaWatts column so that the order changing. Press the green check and again see how the table adjusts. | ||
+ | |||
+ | = Understanding the [[SubTable]] definition = |
Revision as of 23:25, 3 August 2007
A SubTable provides an edit table view for the users of your model, but which displays only a subset of a larger edit table, and may display the rows or columns in a different order from the original. In this mini-tutorial, you'll create a SubTable view.
Preliminaries
Begin by downloading the following model as a starting point: media:California Power Plants2.ANA
After loading the model, you'll should see the following diagram:
Click on the Edit Table button for "Power Plant Data". This model contains data on 34 power plants in California of various types, a portion of which is shown here:
A user can edit this large table, but you may have certain users that need to worry only about Natural Gas plants. For these users, we can provide a SubTable containing only the rows corresponding to Natural Gas plants. We can also sort the table for them, and eliminate the Plant Type column, since it will always beset to Natural Gas.
Defining the SubTable
Steps:
1. Press to enter edit mode.
2. Create a decision node titled Sort By, defined as
Choice(Plant_fields,1,false)
3. Create an index named Gas Plants, defined as
index J := subset( Power_plant_data[Plant_fields='Plant Type']='Natural Gas' ); sortIndex( Power_plant_data[Plant_fields=Sort_by, Plant_id=J ] )
This expression extracts the subset of Plant_IDs in which Plant Type is "Natural Gas". It then sorts by whichever column we've selected in Sort_by.
4. Create an index, Gas_fields, defined as a list of labels:
Plant Name |
County |
Cogen |
MegaWatts |
These are the columns we want to include in the SubTable, in the order we wish for them to appear. Notice that we have excluded Plant Type.
5. Finally, create a variable node titled Gas Plant Data, defined as
SubTable( Power_plant_data[ Plant_id=Gas_plants, Plant_fields=Gas_fields ] )
Your screen should now look like (just before you press Enter to accept the definition):
6. Press the green check button to accept the definition. Notice that the definition panel changes to a SubTable button.
7. Return to browse mode by pressing . (This is so the Choice cells will appear as drop downs when we view the edit table.
8. Press the SubTable button to bring up the SubTable edit view. You should see:
Trying it out
9. In the edit table for Gas Plant Data, change the MegaWatts value for 'UCSD' to 2.83K. Press the green check to accept the change.
10. Examine the original (large) edit table for Power Plant Data. Find the 'UCSD' entry, which should be the top row. Notice that the value in the master table has changed.
11. Try changing other values in each table, pressing the green check in the table where the change is made each time, and watch how the corresponding value changes in the master- or sub-table.
12. Temporarily enter edit mode so that you can change Sort By. Select MetaWatts, for example, and note how the rows of the SubTable change their order. (You may want to switch back to browse mode).
13. In the Subtable, while Sort_By='MegaWatts', change values in the MegaWatts column so that the order changing. Press the green check and again see how the table adjusts.
Enable comment auto-refresher