Contents - Select

 

The Select panel within the Contents pane combines a number of functions related to selection into a single panel.  The Select panel allows making selections using pre-built templates or free form expressions.   It also allows us to save selections and to combine saved selections in Boolean combinations.tech_ravi_sm.png

 

The Select panel operates on tables, drawings, images, and those components in maps.  Templates involving fields for drawings and images will take those fields from the source table.  

 

Important: As with any selection capability, to use the Select panel the table must have at least one btree index in the table. 

 

Please read the Selection topic before proceeding with this topic.

 

To make selections using the Select panel:

 

  1. Open the component (table, drawing, image, map).

  2. Click on the Contents pane and then click on the Select panel.

  3. Using a template, expression or a saved selection, put together a proposed selection.  

  4. That proposed selection will be previewed in the window using blue preview color.

  5. Choose how the selection will be combined with any previously existing selection by choosing a mode in the pull down menu for the command button.

  6. Press the command button, or to launch an equivalent query press the Edit Query button.

Command Button

A command button at the bottom of the Select panel specifies how the selection the panel creates should be applied to any existing selection in the table window.   By default the command button is set to Replace Selection.  

 

il_select_dlg_command_button.png

 

The pull-down menu allows us to choose other selection modes for the command button.   See the discussion below for more detailed information on selection modes in the command button.

Example

eg_select_panel01_01.png

 

We begin with our example drawing of Mexico, showing provinces in Mexico as areas.   The table for this drawing has attributes with data for each province, including a field called Place_name that gives the name of each province.  

 

With the focus on the opened Mexico drawing, click on the Contents pane and then click on the Select panel.  

 

eg_select_panel01_02.png

 

In the Select panel Template tab, click on the Text Contains template and for the Value choose the Place_name field from the list.    Enter 'Durango' in the Search for box.

 

eg_select_panel01_03.png

 

The Select panel will immediately preview the selection to be made in the drawing using blue preview color.    Press the Replace Selection command button to apply that selection.

 

eg_select_panel01_04.png

When we press the Replace Selection button the province of Durango is selected in the drawing, and is shown in red selection color.

Open the Drawing's Table

We now open the drawing's table, Mexico Table.

 

eg_select_panel01_05.png

 

Since selections are shared between every component that depends upon the same table, the table already has the Durango record selected.    With the focus on the table window the Select panel automatically switches context to operating on that table window.  

 

eg_select_panel01_06.png

 

We click on the Text Starts with template, also using Place_name for the Value, and we enter 'S' in the Search for box.   This will select all records where the Place_name value begins with a capital S.  The template is case sensitive when searching for text strings.

 

eg_select_panel01_07.png

 

Right away, the template previews in blue preview color those records that would be selected by the template using those settings.    Previews are shown only in the window that has the focus, so areas in the drawing will not also be previewed.

 

eg_select_panel01_08.png

 

To add these to the existing selection we switch the command button to Add to Selection and then we press the Add to Selection button.

 

eg_select_panel01_09.png

 

The previewed records have been added to the selection and all selected records are now shown in red selection color.

 

eg_select_panel01_10.png

 

The areas corresponding to those selected records are also selected in the drawing, and also shown in red selection color.

Select Panel Tabs

il_select_dlg_tabs.png

 

The Select panel has three tabs:

 

Template Tab

The Template tab provides a list of pre-built selection commands, called templates.  Clicking on a template will highlight it and will open combo boxes that allow us to choose fields and to specify values we would like to use for that template.   

 

To make selections using the Template tab:

 

  1. Open a drawing or a table.

  2. Click on the Contents pane and then click on the Select panel.

  3. Click on the Template tab in the Select panel if not already open.

  4. Click on the name of a template in the list to highlight it.

  5. In the Value box, choose the name of the field to use.

  6. For other boxes, choose another field to use as the argument or enter a number or text for the command to use.

  7. The panel will preview that selection in the drawing or table in blue preview color.

  8. Apply the previewed selection to the table by clicking the command button in the desired mode.

 

Combo boxes generally come pre-loaded with a pull down list of fields in the table and by default contain the name of the first field in the table by alphabetical order.  This makes it easy to choose any field in the table to use with a template without having to keyboard the name of the field.  Combo boxes also generally allow us to manually enter a specific value, such as a field name or a number.  

 

All templates open a Value combo box that allows us to specify the name of a field in the table with which the template works.   The Is not Null and Is Null templates open only the Value combo box while other templates will open additional combo boxes to specify other parameters the template requires.

 

For example, the Equal template will open a Value and Compare to combo boxes. We choose the field name in the Value box and then in the Compare to combo box we can either choose the name of a different field or enter a fixed number.

 

Consider a table of products adapted from the ubiquitous nwind sample database.

 

eg_seldlg_template01_01.png

 

To select records where the Stock is Equal to the Units On Order we launch the Select panel and click on the Equal template. In the Value box we choose the Stock field from the pull down list of fields and in the Compare to box we choose the Units on Order field.

 

eg_seldlg_template01_02.png

 

We can enter numbers into the combo boxes as well.  If we want to select all records where the Stock field is 15 we enter the number 15 into the Compare to box.

 

eg_seldlg_template01_03.png

 

We can enter text strings into the combo boxes.   If we want to select all records where the Name field is Dharamsala Tea we choose the Name field in the Value box and then enter 'Dharamsala Tea' into the Compare to box.   Note that the text string is within single quote ' characters.

 

The Text Contains, Text Ends with and Text Starts with templates also come in Intl or international versions that provide a Language combo box used to choose a collation supported by Manifold.  The Intl forms of those templates also provide checkboxes to Ignore case, Ignore accent and Ignore symbols.   Those options can be very useful in languages where sometimes accents and symbols are used and sometimes not.   

 

For example, it is very common in French to encounter place names which in their official forms may use accents but which in technical uses such as databases do not.  The town of Vendôme in the Loir-et-Cher department of France, for example, is properly spelled with a circumflex accent (the small chevron mark) over the letter o. Nonetheless the name of the town is frequently spelled Vendome without a circumflex accent on web sites and in numerous address databases and other usages, both in France as well as internationally.   To select both Vendôme and Vendome we would check the Ignore accent box for templates that offer it.

 

The Like template utilizes the LIKE operator in SQL to match given patterns while the Text Matches Regexp allows us to specify a regular expression as the pattern to be matched.

 

Note that even though combo boxes for templates allow us to enter a numeric value instead of choosing a field does not mean that it makes sense to do so for all templates.

 

For example, the Is NULL template is used to select all records that have a NULL value.  If we click on the Is Null template a Value combo box opens up, pre-loaded with the name of the first field in the table by alphabetical order.   We can choose the name of any field in the table from the pull-down list of fields available in the Value box and the panel will preview a selection consisting of all records for which that field contains a NULL value.

 

Because combo boxes allow us to enter a number as well, instead of choosing a field name in the Value combo box for Is Null we could have entered a number such as the number 3.  That is possible but it doesn't make sense to do so, since in that case we would be asking the Select panel to select all records for which the number 3 is NULL.   A constant number like 3, of course, is never NULL so the panel would select no records.  tech_lars_sm.png

 

Important: When using the template Text Matches Regexp we enter a regular expression as a string into the Pattern box, surrounded by single quote ' characters and with any backslash characters within the regular expression escaped by a backslash character prefix for each.   See the discussion and examples in the Regular Expressions topic.

Expression Tab

Clicking the Expression tab in the Select panel allows us to make selections with the panel based on SQL expressions that we can build with assistance similar to the Query Builder in the Command Window for SQL.

 

il_seldlg_expression_green_labels.png

 

The Expression tab provides three panes within the panel: an upper pane in which we can write expressions, a middle pane that shows fields in the table and a lower pane that shows operators and functions we can use.  Just as with the query builder in the Command window, double-clicking on a field or an operator or function will add it to the expression we are building.

 

To make selections using the Expression tab:

 

  1. Open a table in a table window.

  2. Click on the Contents pane and then click on the Select panel.

  3. Click on the Expression tab in the Select panel.

  4. Double-click on the names of operators or functions to add them to the expression.

  5. Highlight arguments or other elements of the expression being built and double-click on fields in the field list to add them to the expression.

  6. The panel will preview the selection made by that expression in the table in blue preview color.

  7. Apply the previewed selection to the table by clicking the command button in the desired mode.

 

Example

 

If we want to use the StringContains function in an expression we can find it quickly by entering StringCon into the filter box.   That reduces the number of operators and functions to only those which contain that text.  

 

eg_seldlg_expression01_01.png

 

We double-click on the StringContains function to add it to the expression pane.  

 

eg_seldlg_expression01_02.png

 

We then highlight the <string> part of the function syntax and double-click on the [Name] field to replace <string> with [Name].  We could have manually keyboarded "[Name]" into the expression but double-clicking is faster even with short field names.  Avoiding typographical errors is another plus.  Typographical errors are not a major risk with short field names such as [Name] but when field names are long or difficult to keyboard we can save much time and avoid many errors by double-clicking the field name to enter it into an expression.

 

 

eg_seldlg_expression01_03.png

 

We then highlight the <substring> part of the function syntax and then add the substring we would like to match within single quote ' characters.  

 

If we do this by first adding two single quote characters, that is, beginning with an empty string and start writing the string we can see how the panel will dynamically begin previewing in blue preview color the selection it would make.   

 

eg_seldlg_expression01_04.png

 

 

For example, if we want to find all products in our example table that include the substring Beer in their names we can begin by writing 'B' in the substring section of the function and the panel will preview all products that have a capital B in their name.

 

eg_seldlg_expression01_05.png

 

 

As we continue to write the word Beer to enter 'Be' the preview will indicate fewer products.

 

eg_seldlg_expression01_06.png

 

 

When we finish writing the word the preview indicates just one product.

 

We can, of course, write expressions of arbitrary complexity using any combination desired of fields, mathematical and other operators, functions and so on.

 

Important: When using functions involving regular expressions we pass the regular expression as a string argument to the function, surrounded by single quote ' characters and with any backslash characters within the regular expression escaped by a backslash character prefix for each.   See the discussion and examples in the Regular Expressions topic.

Saved Tab

The Saved tab in the Select panel allows us to save selections made in a table, drawing, image or layer in a map, so the saved selection will persist even if the window is closed, if the Select panel is closed and even if the project is closed.   Click on a saved selection and it will be previewed in blue preview color.  Ctrl-click on a saved selection to select it and the toolbar buttons will be enabled, allowing us to update the saved selection or to delete it.

 

eg_seldlg_saved02_04.png

 

For example, in the illustration above we have two saved selections in the Saved tab that we have saved previously.  If we click on the Anton saved selection the records which are part of that selection will be previewed in the table.   We can click on the Replace Selection command button to select the previewed records.

Saved Selections Change the Table Schema

Selections are saved by adding a new boolean field to the component's table that captures the selected / not selected status of a record.   The value in the field for selected records will be 1 or TRUE.  The value in the field for unselected records will be 0 or FALSE.

 

Important: Using the Saved tab to save a selection will alter the schema of the component's table by adding a new boolean field to the table.  

 

That is something to keep in mind if the table with which we are working is located within a data source where other people might also be using it, in case those other people may be surprised to see the table's schema change.

 

Adding a saved selection to the Saved Tab:

 

  1. Open a component, such as a table, drawing, etc., in a window.

  2. Click on the Contents pane and then click on the Select panel.

  3. Make a selection in the window.

  4. Click on the Saved tab in the Select panel.

  5. Double-click into the blank cell next to the * asterisk row handle.

  6. Enter a name for the new field in the text box and press Enter.

  7. The selection will be saved, and a new boolean field of that name will be added to the table with 1 values for the selected records.

 

Using a saved selection:

 

  1. Open a component, such as a table, drawing, etc., in a window.

  2. Click on the Contents pane and then click on the Select panel.

  3. Click on the Saved tab in the Select panel.

  4. Click on the name of a saved selection in the list.

  5. The saved selection will be previewed in the window in blue preview color.

  6. Apply the previewed selection by clicking the command button in the desired mode.

 

Updating a saved selection:

 

  1. Open a component, such as a table, drawing, etc., in a window.

  2. Click on the Contents pane and then click on the Select panel.

  3. Make a selection in the window.

  4. Click on the Saved tab in the Select panel.

  5. Ctrl-click on the name of a saved selection in the list to select it.  The toolbar will be enabled.

  6. Click the Capture button.

  7. The saved selection field will be updated to save the current selection of the window.

 

 

We can add as many saved selections as we want, with a new boolean field being created in the component's table for each.  Manifold applies no limit to the number of saved selections, although obviously a list of very many saved selections in the Saved tab may be cumbersome to navigate.

 

When opened the Saved tab shows a list of all saved selection fields as well as all other boolean fields in the table along with a blank row with an * asterisk character in the row handle to allow us to add saved selections.  

 

We can use an existing saved selection by clicking on the field name to highlight it in the Saved list.  The selection will then be previewed in blue preview color in the table.   We can combine that saved selection with any current selection in the table by using the Select panel's command button for replace, add, intersect, invert or subtract combinations.

 

Because saved selections are saved by adding a field to the table those saved selections will persist even if we close the table.   When we re-open the table the added field will still be in the table and the Select panel's Saved tab will once again show it. If the table is stored within the project and we save the .map file for the project, the fields added to a table to save selections will still be there when we next open the .map file, even if we move the .map file to a different computer.

Saved Selections Show All Boolean Fields

A Side Effect:  There is nothing magical about fields the Saved tab creates to save the selected status of records.  Such fields are simply boolean type fields just like any other boolean field.  If our table has any existing boolean fields in it when we open the Select panel the Saved tab will show those in the Saved list as well, as if they are saved selections.   That has the side effect of enabling us to rapidly make a selection on the basis of any boolean field that already exists in the table.

 

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 a saved selection boolean field, such as the Anton field in the example below 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 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.

Tables Must be Writable

To save selections the component's table must be writable.  If it is a read-only table Manifold will not be able to create a new boolean field in the table for the saved selection.   

 

Because saved selections are nothing more than an additional boolean field, we can save selections for any table that allows us to create a boolean field in it, even if the table is hosted in some data source external to the project, such as an Oracle or PostgreSQL database.

Example

We open the Products table for the example nwind database and we select two products.

 

eg_seldlg_saved02_01.png

 

 

In the Select panel we click on the Saved tab and we double-click into the blank cell next to the * asterisk row handle.

 

 

eg_seldlg_saved02_02.png

 

 

We enter a name for the saved selection.   The name must be a legal field name in whatever data source stores the table, since the boolean saved selection field that will be added to the table will use that same name.   Press Enter when finished keyboarding the name.   A new saved selection called Anton appears.

 

Next we deselect the two records and select three other records.   To create a second saved selection we double-click into the next blank cell.

 

eg_seldlg_saved02_03.png

 

We enter the name Asian for this saved selection and press Enter.   We now have two saved selections.

 

To use the saved selections we can click on whichever one we want.   To demonstrate, first we choose Edit - Select None to clear the selection in the table.  

 

eg_seldlg_saved02_05.png

 

 

If we click on the Asian saved selection the panel will preview the three records that are in that saved selection.

 

eg_seldlg_saved02_04.png

 

If we click on the Anton saved selection the panel will preview the two records that are in that saved selection.   

 

il_select_saved_replace_command.png

 

To select those records we press the Replace Selection command button.

 

eg_seldlg_saved02_06.png

 

 

Suppose now we click on the Asian saved selection.   That saved selection will be previewed in the table.

 

il_select_saved_add_command.png

 

To add those previewed records to the selection we switch the command button to Add to Selection and press the command button.

 

eg_seldlg_saved02_07.png

 

That adds the previewed records to the selection.

Updating a Saved Selection with Capture

To update a saved selection with a new selection, we make the desired selection, Ctrl-click on the saved selection to be updated and then press the Capture button in the toolbar.

 

Suppose in the nwind sample database scenario we learn that the same company, Anton International, markets products under the Grandma's and Uncle Bob's brands as well as the Chef Anton's brand.    We therefore would like to update the saved selection called Anton so that it selects products for all three of those brands.

 

We begin by selecting the Chef Anton's, Grandma's and Uncle Bob's products.   

 

eg_seldlg_saved02_08.png

 

We then Ctrl-click the Anton saved selection to select it.  That enables the toolbar buttons.   Since the Chef Anton's products were already selected, the combination of red selection color and blue preview color applied by clicking the Anton saved selection results in a blended color for those records.

 

We can then press the Capture button, which updates the Anton saved selection with whatever is the current selection in the table.  

 

eg_seldlg_saved02_09.png

 

If we now press the updated Anton saved selection it will preview the records it will select, which are records for Chef Anton's, Grandma's and Uncle Bob's brand products.

Command Button Modes

The Select panel provides a command button at the bottom of the panel that specifies how the selection it creates will be applied in combination with any selection that already may exist in the subject window.   

 

il_select_dlg_command_button.png

 

We choose a selection mode from the pull-down menu and then the command button will use that mode.   The selection mode we choose from the menu will persist until we choose a different mode for the command button.   The available selection modes available are listed below with a Venn diagram showing how the different command button modes operate.

 

In the Venn diagrams the left-hand circle represents the existing selection in the table and a second, overlapping circle represents the selection that the Select panel would make.  Just as for selections in windows, the existing selection circle is shown in red selection color.  The selection the panel would make is shown in blue preview color. The overlap, that is, those records that are both in the existing selection and which are also are in the preview are shown in blended color that combines the red selection color with blue preview color.  The final result of pressing the Select panel command button in the given mode is shown entirely in red selection color.

 

il_sel_replace.png

Replace Selection -  Select all records in the preview and deselect all other records.   This operation takes whatever records would be selected by the Select panel and makes those the only records selected, ignoring anything before.

 

il_sel_add.png

Add to Selection -  Select all records that were previously selected plus in addition select all records that the panel would select.  Any records that were previously selected and which the panel would also select will, of course, remain selected.  Note that if there was no prior selection that Add to Selection is equivalent to Replace Selection: in both cases the result is what the Select panel would select.

 

il_sel_intersect.png

Intersect with Selection - Select only those records that were previously selected and which also would be selected by the Select panel action.   If there was no prior selection the result would be to select no records.

 

il_sel_invert.png

Invert with Selection -  An "anti-intersect" operation: everything except the intersection.  Select all records previously selected and all records the Select panel action would select, except those records which were previously selected and also would be in the Select panel's selection.   This is equivalent to an Add to Selection that simultaneously de-selects any Intersect with Selection records.   If there was no prior selection the result of an Invert with Selection is equivalent to both Add to Selection and to Replace Selection since in all three cases the result is what the Select panel would select.  

 

il_sel_subtract.png

Subtract from Selection - De-select all records that are in the Select panel's selection.  If there was no prior selection this is the same as selecting no records.

 

Note that since other commands remain fully operational when the Select panel is open we can still use menu commands such as Edit - Select All, Edit - Select None and Edit - Select Inverse.  We can use mouse selection methods as well.   Between those commands and the rich set of selection capabilities provided by the Select panel we can make exactly the selection we want.

Dynamic Updating

The Select panel dynamically updates itself given any changes in the table's schema.  For example, if we choose Edit - Schema and then add a new boolean field to the table the available fields in the Expression tab's expression builder will be updated with the new field and the new boolean field will also appear in the Saved tab as a saved selection.    If we delete all btree indexes from the table the Select panel will automatically be disabled, since it cannot work with tables that do not have at least one btree index.

Simultaneous Use of Other Facilities

When we have the focus on an open window the Select panel works with that particular window.  At the same time we can open other windows and do other work with Manifold, going back and forth between the other work and the Select panel.  The Select panel will automatically switch context to apply to whatever open window has the focus.

 

Notes

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 panels overlapping the table windows.  There is no requirement to overlap a table window with a panel for that table window but doing so allows us to fit more panels and tables into a smaller illustration.

 

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

 

See Also

Contents Pane

 

Tables

 

Selection

 

Drawings

 

Example: Using the Select Panel Template Tab -  A sequence of actions using Select panel templates.

 

Example:  Using the Select Panel Saved Tab - How to save selections and then use them later.

 

Example: Construct JSON String using Select and Transform - Use the  Select and Transform panels 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.