Example: Using the Select Dialog Saved Tab

This example shows how to use the Select Dialog Saved tab to save selections and to then re-use those selections in various combinations.


In this example we will work with a Products table created from the ubiquitous nwind example database.  The table shows a list of products for a hypothetical vendor of food and beverage products.   For the sake of this example we have right-clicked on some of the column headings and have chosen Hide to hide some of the fields, thus providing less-cluttered illustrations.




In the table we have Ctrl-clicked on the row handles of two of the records to select them.   In the main menu we choose Edit - Select to open the Select dialog.   We click on the Saved tab.




The table has no boolean fields in it, including no saved selection boolean fields so the list in the Saved tab is empty but for the <new field> option.




We click on the <new field> option to choose it.




At the bottom of the dialog a text box appears which allows us to provide a name for the new saved selection field.  We will call it Anton because the two selected products are both in the Chef Anton's product line.  We press the Add button.




Immediately in the Saved list the Anton saved selection appears.




If we look at the table we see that a new field called Anton has been added.  The new Anton field is a boolean field with values of 1 or TRUE for each record that is in the saved selection and 0 or FALSE for each record that is not in the saved selection.     This method of saving selections by using a boolean field is extremely simple and very open and obvious.  It is hard to mess up.




Suppose now we choose Edit - Select None in the main menu to clear the selection.  




Back in the Select dialog we can retrieve our saved selection instantly by simply clicking on the Anton field to highlight it in the Saved tab.  The dialog knows that any record with a 1 in the Anton field should be selected.  





The dialog immediately previews that saved selection for us in blue preview color in the table.


We can now use that saved selection however we like in combinations specified by the command button at the bottom of the dialog.  We could click on the default Replace Selection command button mode to make that saved selection the current selection in the table.   If the table already had some other selection we could use one of the other modes for the command button to add to the selection, subtract from the selection, intersect with the selection or invert with the selection.  


Suppose we would like to change a saved selection... how can we do that?




Suppose, for example, that Chef Anton adds to his empire of food products by acquiring the makers of the licorice syrup and fish roe products also sold by our hypothetical vendor.  We would like to add these products to the saved selection we call Anton.   That's easy to do.  We make the selection we want in the table and then...




...we click on the Anton saved selection to highlight it in the Saved list.   We press the Update button and the Anton saved selection will now be updated to contain whatever is the current selection in the table.




If we take a close look at the contents of the Anton field in the table, we see that now all of the selected products have a 1 in the Anton field.


It is worth repeating the saved selections mechanism in Manifold is deliberately kept simple so it is easy to use and open to alternative ways of using the mechanism.   For example, we didn't have to update the Anton field by using the Update button.   We could have manually added desired records to the saved selection by manually changing the values in the Anton field for those records from 0 to 1 or we could have done so using SQL.


For that matter there is nothing magical about the boolean fields used to store saved selections.  Any boolean field that is in the table will appear in the Saved list and could be used by the Select dialog as a saved selection.




For example, suppose our table had a boolean field in it called Promo that was used to mark those products which are part of some marketing promotion, such as a special discount.   A product with a value of 1 or TRUE in the Promo field is eligible for the discount and those products with a value of 0 or FALSE in the Promo field are not eligible.




Looking at the schema of the table there is nothing special about the Promo field: it is just a boolean field.  Note that the schema shows all fields in the table, including those we have hidden to allow less-cluttered illustrations.




If our table did have a boolean field called Promo it would also appear in the Saved list in the Select dialog.  If we clicked on it to highlight the Promo field in the Saved list, the Select dialog would interpret the values in that field for use as a saved selection, previewing them in blue preview color in the table just as it did for the Anton saved selection field.   This ends up selecting all records that are eligible for the marketing promotion.


That is a very useful effect as quite often we might want to make selections in tables based on the values of existing boolean fields, for example, selecting all records participating in a promotion.   Because boolean fields usually indicate some sort of included or not included status they naturally lend themselves to use as selection criteria for records being in or out of a selection.


That useful effect might lead to confusion if we forget which boolean fields we added to the table for saved selections and which were part of the original structure of the table.  For example, if we do not work with this table for a few weeks or months the next time we open it we might not remember exactly what was intended with the Anton field that is now part of the table.


To avoid confusion with boolean fields not intended to store saved selections it makes sense to choose names for the selections which we save that will make it immediately obvious those fields were intended to save selections.


We might get in the habit of appending _s to saved selection names as a reminder the field is for a saved selection, using a name like Anton_s in the above example.    That will make clear later on which boolean fields were added to the table to save selections and which boolean fields were part of the original schema of the table.


If we want to use saved selections only for the duration of a particular work session and not permanently change the schema of a table that is easy to do: when we are finished using the saved selections we highlight them in the Saved tab and press the Delete button, which removes that field from the table.



Example tables - In this topic we use tables adapted from the ubiquitous nwind example database.  To keep the illustrations as small as possible to fit into this documentation we will often take a moment to hide the mfd_id field and to hide other fields in the table window that are not being used or are not central to the example.  We also frequently show dialogs overlapping the table windows.  There is no requirement to overlap a table window with a dialog for that table window but doing so allows us to fit more dialogs and tables into a smaller illustration.


Transition from pre-Radian products -  The Select dialog provides within a single dialog the functionality of the Selection Toolbar, Saved Selections pane and Selection Modes in pre-Radian versions of Manifold GIS.


See Also



Select Dialog


Example: Using the Select Dialog Template Tab -  A sequence of actions using Select dialog templates.


Example: Using the Select Dialog Window Tab - How to transfer selections between windows.


Example: Multiple Windows with Multiple Select Dialogs - Open multiple windows for the same table and open a Select dialog for each. This shows how multiple Select dialogs providing multiple selections and multiple previews for the same table can be opened and used at the same time.   


Example: Construct JSON String using Select and Transform - Use the Select and Transform dialogs to manually construct a JSON string using values from other fields in a table. Shows how we can manipulate text to build desired contents in a field.