Connect Add-in Pane to active map?

4900
17
07-17-2016 08:46 AM
by Anonymous User
Not applicable

I am displaying a data grid of custom information in my Pro add-in.  I have added this to a pane, however, when this pane is activated, the Contents dock pane is empty until a map view is again set as the active pane.  I would like the Contents to remain populated with layers from the active map view, similar to how charts and attribute table panes work.  When I add the data grid to a dock pane instead of a ViewStatePane, I do get this behavior, but then I cannot dock this pane to the map view. Is there a way to do this? 

0 Kudos
17 Replies
JodiLuostarinen
New Contributor II


ESRI Response to Question on 7/5/2007:

I have heard back from additional resources on this issue and currently there is no control for a table in ArcGIS Pro 2.0 SDK. Therefore, to implement your own pane with an attribute table, you would have to create your own with a data grid and pass that to the content property in the DAML. Alternatively, you can use the sample from GitHub that creates its own data grid and displays the attribute table with the needed fields in a new pane: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Authoring/LayersPane This can be implemented in an ArcGIS Pro Map Pane Impersonation from the templates via ArcGIS Pro 2.0 SDK.

0 Kudos
SamanthaHughes1
New Contributor II

Is there any easy way to show the attribute table when clicking a button for a specific table? I know which layer I want the attribute table to show for.

I basically want to replicate, the right click and "Show Attribute Table" function and it is already open within my map.

TIA

0 Kudos
JodiLuostarinen
New Contributor II

This is just a thought, but have you looked-up the DAML id for the open

attribute table tool, and tried something like this?

//Select From Map

// System.Windows.Input.ICommand cmd =

FrameworkApplication.GetPlugInWrapper("esri_mapping_selectByRectangleTool")

as ICommand;

//if ((cmd != null) && cmd.CanExecute(null))

// cmd.Execute(null);

Jodi Luostarinen

CEO Quartic Solutions

1804 Garnet Ave. #447

San Diego, CA 92109

mobile: (619) 602-7606

www.quarticsolutions.com

Wolf
by Esri Regular Contributor
Esri Regular Contributor

Jodi is correct this code snippet below opens the attribute table for the current select feature layer in the Content Dockpane:

protected override void OnClick()
{
 var cmdOpenAttributeTable = FrameworkApplication.GetPlugInWrapper("esri_editing_table_openTablePaneButton") as ICommand;
 if (cmdOpenAttributeTable != null)
 {
  if (cmdOpenAttributeTable.CanExecute(null))
  {
   cmdOpenAttributeTable.Execute(null);
  }
 }
}

DAML Ids for built-in commands are listed here: https://github.com/Esri/arcgis-pro-sdk/wiki/ArcGIS-Pro-DAML-ID-Reference

And in order to select a feature layer in the TOC you can use the snippet below:
https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-MapExploration#select-all-feature-layers-in-...

Put the two snippets together you get the following solution which opens the attribute tables for all feature layers:

protected override void OnClick()
{

    //Get the active map view.
    var mapView = ArcGIS.Desktop.Mapping.MapView.Active;
    if (mapView == null)
        return;

    //Zoom to the selected layers in the TOC
    var featureLayers = mapView.Map.Layers.OfType<FeatureLayer>();
    mapView.SelectLayers(featureLayers.ToList());


    var cmdOpenAttributeTable = FrameworkApplication.GetPlugInWrapper("esri_editing_table_openTablePaneButton") as ICommand;
    if (cmdOpenAttributeTable != null)
    {
        if (cmdOpenAttributeTable.CanExecute(null))
        {
            cmdOpenAttributeTable.Execute(null);
        }
    }
}
SamanthaHughes1
New Contributor II

Thanks Wolfgang,

I seem to have the strangest error when running this, the attribute table opens up but then get an exception related to the width of the window and it all crashes out before the data within the window completely opens. I am going to wait until I am back in work tomorrow to try again before I completely go nuts.

So I almost got there. Thank you very much for pointing out the DAMLs - I have now found the reference page.

vb version:

Try

Dim cmdOpenAttributeTable As ICommand = FrameworkApplication.GetPlugInWrapper("esri_editing_table_openTablePaneButton")
cmdOpenAttributeTable.Execute(Nothing)

Catch

MessageBox.Show("Error Opening Attribute Table")
End Try

0 Kudos
SamanthaHughes1
New Contributor II

Hi Wolf, have you ever seen this error before? (My code below)

Dim cmdOpenAttributeTable As ICommand = FrameworkApplication.GetPlugInWrapper("esri_editing_table_openTablePaneButton")

If cmdOpenAttributeTable IsNot Nothing Then
   If (cmdOpenAttributeTable.CanExecute(Nothing)) Then
      cmdOpenAttributeTable.Execute(Nothing)
   End If
End If

This error appears after opening the attribute table before the data has loaded. Is it a bug? I have read that it could be down to screen resolution but struggling to resolve.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I tried your code snippet (in VB) and didn't get any errors.   Are you able to open the Attribute tables from within ArcGIS Pro?  If not it's probably a good idea to refresh your display device drivers to the latest available version.  However, if it works from within Pro I would first look and make sure there are NO other add-ins running at the time.  To check you can delete all files from the well-known add-ins location, or when you open Pro you can click on 'About ArcGIS Pro' and then use the add-in manager to remove all existing add-ins.  Then I would recompile the sample and try again.  It is possible that the error you see is getting thrown by another add-in that is still running without your knowledge.

0 Kudos
SamanthaHughes2
New Contributor

Hi Wolf,

Thanks for testing my code and reassuring me that there is nothing wrong with it. I am tried all the above, and I am unable to automate opening an attribute table.

I have refreshed my display drivers too even though I can open an attribute table directly in Pro and removed all the addins from my add-in manager menu.

Bit random ey? I have emailed in so hopefully someone will have some more ideas for me to try.

Just wanted to say thanks for some great ideas to debug.

S*

0 Kudos