Retrieve feature attributes from the Attributes Pane via a context menu

1325
7
Jump to solution
09-27-2021 06:29 AM
MichaelHirschheimer
Esri Contributor

I've added a context menu to the Attributes Pane when you right click on a feature.
Upon clicking on the context item, I want to retrieve attributes from the feature.

Using the screenshot, upon clicking on 'Mike's UN Rules Item', I want to retrieve the Objectid and it's layer name.  Results would be:     840 and Pipeline Device


MichaelHirschheimer_0-1632748895983.png

Does anyone have an example of how to get this information?

I'm using Pro SDK 2.8

 

Thanks,

Mike

1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Mike, 

 

I have added an issue to our backlog for this to be addressed.  It is too late for it to be included in ArcGIS Pro 2.9 but we will consider it for the next release. 

 

Thanks

Narelle

View solution in original post

7 Replies
NarelleChedzey
Esri Contributor

Hi Mike, 

 

Typically with items on a context menus you would use the FrameworkApplication.ContextMenuDataContext property (https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic10164.html)  and then cast this to an appropriate public API class to retrieve the context object. 

 

Unfortunately in this case there is no public API class in the Editing module that corresponds to an item in the Attributes tree view.   We can look at adding something to a future release to facilitate your scenario., 

 

Thanks

Narelle

 

0 Kudos
MichaelHirschheimer
Esri Contributor

Hi Narelle,

I thought the “Flash” context menu item was using the same attributes that I’m trying to get retrieve, the FeatureLayer and the objectid.  Is the Flash item being handled differently than what I’m trying to do?

MichaelHirschheimer_2-1632769186409.png

 

MichaelHirschheimer_3-1632769193977.png

 

 

Thanks,

Mike

0 Kudos
NarelleChedzey
Esri Contributor

Mike,

Essentially the flash item you see on the context menu is a button (similar to what you have for Mikes UN Rules Item) that obtains the mapMember and objectID of the feature that you right click on in the Attributes pane.   It would then call the FlashFeature API call that you referenced.   

So in psuedo code it would be like this

 

  internal class FlashButton : Button
  {
    protected override void OnClick()
    {
      var context = FrameworkApplication.ContextMenuDataContext;
      var items = context as IEnumerable<AttributeTreeItem_InternalClass>;
      var item = items.FirstOrDefault();
      if (item != null)
      {
        MapView.Active.FlashFeature(item.Layer, item.ObjectID);
      }
    }
  }

 

So yes it is doing exactly the same thing that you want to do. 

The key difference is that the AttributeTreeItem_InternalClass is internal only to the Editing code.  As an add-in developer, you only have access to classes and methods that are in the public API.  Right now, the public API is missing the class used in line 6 to translate from the context object in order to obtain the layer and objectID. 

 

Hope this is clear. 

 

Narelle

 

0 Kudos
MichaelHirschheimer
Esri Contributor

Hi Narelle,

Thanks for the additional information.  I now understand why this isn't do-able at Pro 2.8.

Is there anything I can submit to get this functionality considered for a future release?

Thanks,

Mike

 

0 Kudos
NarelleChedzey
Esri Contributor

Mike, 

 

I have added an issue to our backlog for this to be addressed.  It is too late for it to be included in ArcGIS Pro 2.9 but we will consider it for the next release. 

 

Thanks

Narelle

VqSp85
by
New Contributor

Hi,

I resume this topic because we would need on a important project for big telco company to have access to these objects,
would it be possible to know in which version of the SDKs they will be made available?

0 Kudos
MichaelHirschheimer
Esri Contributor

@newbiedotnetguy   @VqSp85 

The enhancement described in this thread will be included in the upcoming Pro SDK 3.1 release.

It will also be documented in the Editing Pro Concepts pages.

 

Thanks,

Mike