Any API in ArcGIS Pro SDK to set the layer attribute field order. Manually Data Design used or Arcpy also another option. However, I did not see any API in Arcpro SDK. I checked "SetFieldOrderAsync" but it required the active table view. But I plan to implement the order for many layers after adding the features to the map.
Thank you for the advice
Solved! Go to Solution.
Ok, now I used the idea from the link you provided ... "Reordered field descriptions". What I did here is, I got the field description (list of field object) from the layer and reordered them in the new list of field descriptions...then I used the SetFieldDiscriptions method and now all looks good.
I would love to learn if there is another better option to reorder the layer field in the attribute table.
Thank you @GKmieliauskas
I had no success with SetFieldOrderAsync. I ended up with the same solution as you did. Something like below:
theCIMBaseLayer = layer.GetDefinition();
theCIMFeatLayer = (CIMFeatureLayer)theCIMBaseLayer;
theFieldDesc = theCIMFeatLayer.FeatureTable.FieldDescriptions;
theFieldList = theFieldDesc.ToList();
int theNum = 1;
theFieldDescNew = new CIMFieldDescription[theFieldDesc.Length];
foreach (CIMFieldDescription item in theFieldList)
{
if (item.FieldName == "Name")
{
theFieldDescNew.SetValue(item, 0);
}
else
{
theFieldDescNew.SetValue(item, theNum);
}
theNum += 1;
}
theCIMFeatLayer.FeatureTable.FieldDescriptions = theFieldDescNew;
layer.SetDefinition(theCIMFeatLayer);
Hi,
Look at the Community solution here. Maybe it could help you.
Hi ,
I am interested in the layers on the map level, not the database level. The community solution has suggestions on database level but layer level.
Ok, now I used the idea from the link you provided ... "Reordered field descriptions". What I did here is, I got the field description (list of field object) from the layer and reordered them in the new list of field descriptions...then I used the SetFieldDiscriptions method and now all looks good.
I would love to learn if there is another better option to reorder the layer field in the attribute table.
Thank you @GKmieliauskas
I had no success with SetFieldOrderAsync. I ended up with the same solution as you did. Something like below:
theCIMBaseLayer = layer.GetDefinition();
theCIMFeatLayer = (CIMFeatureLayer)theCIMBaseLayer;
theFieldDesc = theCIMFeatLayer.FeatureTable.FieldDescriptions;
theFieldList = theFieldDesc.ToList();
int theNum = 1;
theFieldDescNew = new CIMFieldDescription[theFieldDesc.Length];
foreach (CIMFieldDescription item in theFieldList)
{
if (item.FieldName == "Name")
{
theFieldDescNew.SetValue(item, 0);
}
else
{
theFieldDescNew.SetValue(item, theNum);
}
theNum += 1;
}
theCIMFeatLayer.FeatureTable.FieldDescriptions = theFieldDescNew;
layer.SetDefinition(theCIMFeatLayer);
hi @EricElder
Great you tested that on your end. The SetFieldOrderAsync only works if you have an active attribute view. I don't think it even updates the layer file once applied to the active attribute view.