How to get attributes of a featurelayer to show in custom datagrid

1907
8
Jump to solution
02-18-2019 05:09 AM
TomGeo
by
Occasional Contributor III

I am working on an add-in where I provide the user with a combobox, to select one of the featurelayers available in the toc.

On change of the index of the combobox I want to read all attributes (columns and rows) of the specific featurelayer to be shown in a datagrid. Sure enough, in the end I do not want to show all columns of the attribute table but want to specify two or three columns.

It is basically like the attribute table, only that I want to have it within my own ui and show only pre-defined columns.

I looked through the api and the ProSnippets, but didn't find an example to do so. I do not have any selected features to show the attributes from, but need the attributes of all features.

Anybody who can point me the right direction?

Cheers Thomas

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry Thomas,

 There is no easy way to convert to a Datatable object.  I personally like to use the Datatable because of its capabilities and wide support by user controls, hence i used a DataTable in the sample i referenced above.  You can also look at the new TableControl with a ProGuide here:  https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-TableControl and the corresponding sample here: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/TableControl.  

View solution in original post

8 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Hi Thomas,

 You can look at this sample here https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/IdentifyWindow 
I think this does pretty much what you need, except you need to get all features instead of just the selected features.  You also have to add your own 'column' filter logic in the GetSelectedFeaturesAsync method.

Hope this helps,

Wolf

TomGeo
by
Occasional Contributor III

Hi Wolfgang,

thanks for the reply and the linked example. It seems as if there's (almost) everything I need to get going. However, when i want to build the solution then I have the problem

Error        C:\Program Files\ArcGIS\Pro\bin\Esri.ProApp.SDK.Desktop.targets not found.    IdentifyWindow    c:\...\...\source\Samples\IdentifyWindow\IdentifyWindow.csproj    139    

How can I adjust the path in VisualStudio, since I do not have my programs installed in the standard directories?

Gruß Thomas

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
UmaHarano
Esri Regular Contributor

Hi Thomas,

Since your Pro install location is different than the one used in the sample solution, you can use the "Pro Fix References" utility. You can get this utility by installing the ArcGIS Pro SDK for .NET (Utilities) vsix package from Visual Studio Marketplace.

More information on the utility is here: Home · Esri/arcgis-pro-sdk Wiki · GitHub 

Run this utility on the sample solution. You will then be able to build it.

Thanks

Uma

0 Kudos
TomGeo
by
Occasional Contributor III

Thanks for your answer! I was altering the paths just now by hand in the csproj file and that seems to work, but I was already thinking this won't be the right way to do it.

See you guys in Palm Springs... 🙂

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
UmaHarano
Esri Regular Contributor

Manually changing the paths in the csproj should work, but you could miss a few paths.Also, there are entries in the config.daml that needs to be fixed too - So the tool makes this simpler

Thanks! See you in Palm Springs.

Uma

0 Kudos
TomGeo
by
Occasional Contributor III

Hi Wolfgang and Uma,

is there a possibility to convert an ArcGIS.Core.Data.Table object into a System.Data.Datatable object? Looking at the linked example the DataTable of selected features is built-up iterative. Any chance to avoid that?

Thomas

- We are living in the 21st century.
GIS moved on and nobody needs a format consisting out of at least three files! No, nobody needs shapefiles, not even for the sake of an exchange format. Folks, use GeoPackage to exchange data with other GIS!
0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Sorry Thomas,

 There is no easy way to convert to a Datatable object.  I personally like to use the Datatable because of its capabilities and wide support by user controls, hence i used a DataTable in the sample i referenced above.  You can also look at the new TableControl with a ProGuide here:  https://github.com/Esri/arcgis-pro-sdk/wiki/ProGuide-TableControl and the corresponding sample here: https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Map-Exploration/TableControl.  

by Anonymous User
Not applicable

Hi Thomas - 

Could you use the Table object with a feature class attribute table that has some of its fields "hidden", i.e., that has some of it's Fields made "non-Visible"? 

Hiding Fields using the UI: 

Hide columns in a table—ArcGIS Pro | ArcGIS Desktop 

Attributes IsVisible Property using the Code: 

ArcGIS Pro 2.3 API Reference Guide  

Cheers, 

+ bill