How can one programmatically sort a table on a given field? This functionality is achieved in Pro by the user right clicking on a given field and electing to sort descending or ascending on that field. Is this attainable using the pro sdk?
@UmaHarano @CharlesMacleod @Wolf
Solved! Go to Solution.
Starting with Release 3.1, you can use the TableView class as described here: ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki (github.com)
and specifically the SortAscending Method: SortAscending Method (TableView)—ArcGIS Pro
The code would look like this:
var tv = TableView.Active;
if (tv == null)
return;
// sort the active field descending
if (tv.CanSortDescending)
tv.SortDescending();
// sort the active field ascending
if (tv.CanSortAscending)
tv.SortAscending();
// peform a custom sort programmatically
if (tv.CanCustomSort)
{
// sort fields
var dict = new Dictionary<string, FieldSortInfo>();
dict.Add("STATE_NAME", FieldSortInfo.Asc);
dict.Add("CITY_NAME", FieldSortInfo.Desc);
await tv.SortAsync(dict);
}
// perform a custom sort via the UI
if (tv.CanCustomSort)
tv.CustomSort();
Starting with Release 3.1, you can use the TableView class as described here: ProConcepts Map Exploration · Esri/arcgis-pro-sdk Wiki (github.com)
and specifically the SortAscending Method: SortAscending Method (TableView)—ArcGIS Pro
The code would look like this:
var tv = TableView.Active;
if (tv == null)
return;
// sort the active field descending
if (tv.CanSortDescending)
tv.SortDescending();
// sort the active field ascending
if (tv.CanSortAscending)
tv.SortAscending();
// peform a custom sort programmatically
if (tv.CanCustomSort)
{
// sort fields
var dict = new Dictionary<string, FieldSortInfo>();
dict.Add("STATE_NAME", FieldSortInfo.Asc);
dict.Add("CITY_NAME", FieldSortInfo.Desc);
await tv.SortAsync(dict);
}
// perform a custom sort via the UI
if (tv.CanCustomSort)
tv.CustomSort();
You can also search for the videos from Dev Summit 2023 specifically the session:
"Intermediate Data Visualization Using Table Controls"
You can find the session resources here: Tech Sessions · Esri/arcgis-pro-sdk Wiki (github.com)