Is there a way to freeze attribute table fields programmatically in ArcGIS Pro SDK? Ideally one would open a feature layer or table and have the fields be pre frozen to always appear to the left side of the attribute table. @UmaHarano @Wolf
What do you mean with frozen?
@Wolf In Pro, when you open an attribute table, you can freeze some fields so that they always appear at the start of the table. I've updated the question with more details.
Hi Marvis,
I talked to the developers and we don't currently have the capability to freeze fields programmatically in the TableControls (Pro out-of-box and the API TableControl) nor are there any workarounds. The developers will add this feature as an enhancement after the 2.8 release.
Do you know if this enhancement was added to 2.9 and beyond and if so, what is the name of the method? @Wolf @UmaHarano @CharlesMacleod
Hi
Here is the method: SetFrozenFieldsAsync Method (TableView)
Sets the specified fields to be frozen in the table view. Frozen fields are promoted to be the first visible fields in the table view and stay visible as the table view is scrolled horizontally. A divider bar is placed between the frozen fields and the remaining fields in the table. The specified list of fields are added to any existing fields that are already frozen.
@UmaHarano the SetFrozenFieldsAsync Method (TableView) method requires that one has an active table view. I am looking to freeze the fields for a given table in the code such that when the table is opened, the desired fields are pre-frozen. Currently, I set the desired fields to highlighted utilising
fielddescription.IsHighlighted = true
Is there something similar for setting specific fields to frozen without an active table view?
One idea is to subscribe to the ActiveMapViewChanged event.
When the active map view changes, you can check if the table you are interested in is "Active". Then you can freeze the field. Something like this code below:
ArcGIS.Desktop.Mapping.Events.ActiveMapViewChangedEvent.Subscribe(OnActiveViewChanged);
private void OnActiveViewChanged(ActiveMapViewChangedEventArgs args)
{
var pane = args.IncomingView;
if (pane == null)
return;
if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane)
{
if (tablePane.MapMember.Name == "U.S. States (Generalized)") //check for your map member name here
{
List<String> fieldToFreeze = new List<string> { "STATE_NAME" }; //your field goes here
TableView.Active.SetFrozenFieldsAsync(fieldToFreeze);
}
}
}
This works. Thank you!