ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / GetStandaloneTablesAsFlattenedList Method
Example

In This Topic
    GetStandaloneTablesAsFlattenedList Method (Map)
    In This Topic
    Returns a read only flat list of StandaloneTables where nested groups are not preserved.
    Syntax
    Public Function GetStandaloneTablesAsFlattenedList() As IReadOnlyList(Of StandaloneTable)
    public IReadOnlyList<StandaloneTable> GetStandaloneTablesAsFlattenedList()

    Return Value

    A IReadOnlyList of StandaloneTables
    Example
    Find table templates belonging to a standalone table
    // retrieve editing templates associated with standalone tables in the active map.
    await QueuedTask.Run(() =>
    {
      //Get a particular table template
      var tableTemplate = activeMap.FindStandaloneTables("Address Points").FirstOrDefault()?.GetTemplate("Residences");
      //Get all the templates of a standalone table
      var ownersTableTemplates = activeMap.FindStandaloneTables("Owners").FirstOrDefault()?.GetTemplates();
      var statisticsTableTemplates = activeMap.GetStandaloneTablesAsFlattenedList().First(l => l.Name.Equals("Trading Statistics")).GetTemplates();
    });
    Remove a table template
    // Removes predefined editing templates associated with the specified standalone table.
    await QueuedTask.Run(() =>
    {
      var tableTemplate = table.GetTemplate("Template1");
      //Removing a table template
      table.RemoveTemplate(tableTemplate);
      //Removing a template by name
      table.RemoveTemplate("Template2");
    });
    Retrieve a table from its container
    {
        var container = MapView.Active.Map;
    
        //the map standalone table collection
        var table = container.GetStandaloneTablesAsFlattenedList()
                                .FirstOrDefault(tbl => tbl.Name == "EarthquakeDamage");
    
        //or from a group layer
        var grp_layer = MapView.Active.Map.FindLayers("GroupLayer1").First() as GroupLayer;
        var table2 = grp_layer.FindStandaloneTables("EarthquakeDamage").First();
        //or         grp_layer.GetStandaloneTablesAsFlattenedList().First()
        //or         grp_layer.StandaloneTables.Where(...).First(), etc.
    
        //show the table in a table view 
        //use FrameworkApplication.Current.Dispatcher.BeginInvoke if not on the UI thread
        FrameworkApplication.Panes.OpenTablePane(table2);
    }
    Remove a Standalone table
    {
        //get the first group layer that has at least one table
        var grp_layer = MapView.Active.Map.GetLayersAsFlattenedList()
          .OfType<GroupLayer>().First(g => g.StandaloneTables.Count > 0);
    
        //Note: Run within a QueuedTask
        //get the tables from the map container
        var tables = map.GetStandaloneTablesAsFlattenedList();
        //delete the first...
        if (tables.Count() > 0)
        {
            map.RemoveStandaloneTable(tables.First());
            //or delete all of them
            map.RemoveStandaloneTables(tables);
        }
    
        //delete a table from a group layer
        //assumes it has at least one table...
        grp_layer.RemoveStandaloneTable(grp_layer.StandaloneTables.First());
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also