Customization in the attribute grid of Inspector

811
6
Jump to solution
05-19-2023 03:42 AM
ShaneTsh
New Contributor II

 

Hi,

I am using the Inspector class to display the attribute grid for any table for one oid using Load method of the inspector. But this will load the whole table with its columns and values. But I want to achieve 2 things:

1. Can we load the table for that one oid with some fixed columns with their values but not the whole table?

2. I have another button in my custom UI which will save some data not from the attribute grid but under the implementation of that button. So this button can update data for few of those default columns. Can we highlight those changed columns in some way for example can we make those column names as bold or some other way to highlight those columns which will tell that these are the modified columns?

@Wolf  @GKmieliauskas @UmaHarano @CharlesMcLeod  @NarelleChedzey 

Tags (1)
0 Kudos
2 Solutions

Accepted Solutions
NarelleChedzey
Esri Contributor

If you are using ArcGIS Pro 3.1 or higher there is also the InspectorProvider class that allows customization of field visibility, editability, display name, etc in the inspector when it is displayed as an embeddable control.   These customizations are different from using the IDisplayTable to make the changes. 

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10294.html

 

Here's an example that shows how to hide a field from the inspector grid. 

  internal class CustomProvider : InspectorProvider
  {
    public override bool? IsVisible(Attribute attr)
    {
      if (attr.FieldName == "POP1990")
        return false;

      return true;
    }
  }

 

 

And now when creating the inspector grid use the following

  var provider = new CustomProvider();
  _featureInspector = provider.Create();

  // create a new instance for the inspector
  // create an embeddable control from the inspector class to display on the pane
  var icontrol = _featureInspector.CreateEmbeddableControl();

 ...

 

We don't currently have any support for the second part of your question - being able to highlight the columns that have been modified. 

 

Narelle

 

View solution in original post

NarelleChedzey
Esri Contributor

Sorry.  You also need to override an additional method in your implementation of the InspectorProvider.   Add the override for the AttributesOrder.   See the code snippet below. 

Also note that your add-in does not need to iterate through the attributes calling the IsVisible method after having loaded it.  The internal Pro code of the inspector control code calls the InspectorProvider methods.   All the add-in needs to do is create the inspector from your provider, create the embeddable control and then load the row. 

 

Narelle

  internal class CustomProvider : InspectorProvider
  {
    public override bool? IsVisible(Attribute attr)
    {
      if (attr.FieldName == "POP1990")
        return false;

      return true;
    }

    public override IEnumerable<Attribute> AttributesOrder(IEnumerable<Attribute> attrs)
    {
      return attrs;
    }
  }

 

View solution in original post

6 Replies
ShaneTsh
New Contributor II
0 Kudos
GKmieliauskas
Esri Regular Contributor
0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I think a 'RowTemplate' does a lot of the items on your punchlist:  ProConcepts Editing · Esri/arcgis-pro-sdk Wiki (github.com)

Also @GKmieliauskas  shows a solution to turn visibility on/off

0 Kudos
NarelleChedzey
Esri Contributor

If you are using ArcGIS Pro 3.1 or higher there is also the InspectorProvider class that allows customization of field visibility, editability, display name, etc in the inspector when it is displayed as an embeddable control.   These customizations are different from using the IDisplayTable to make the changes. 

https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic10294.html

 

Here's an example that shows how to hide a field from the inspector grid. 

  internal class CustomProvider : InspectorProvider
  {
    public override bool? IsVisible(Attribute attr)
    {
      if (attr.FieldName == "POP1990")
        return false;

      return true;
    }
  }

 

 

And now when creating the inspector grid use the following

  var provider = new CustomProvider();
  _featureInspector = provider.Create();

  // create a new instance for the inspector
  // create an embeddable control from the inspector class to display on the pane
  var icontrol = _featureInspector.CreateEmbeddableControl();

 ...

 

We don't currently have any support for the second part of your question - being able to highlight the columns that have been modified. 

 

Narelle

 

ShaneTsh
New Contributor II

@NarelleChedzey  I tried to use the InspectorProvider but I am getting null reference exception when I am loading my table with a oid

inspectorProvider = new CustomInspectorProvider();
inspector = inspectorProvider .Create();
var embeddableControl = inspector .CreateEmbeddableControl();
inspectorViewModel = embeddableControl.Item1;
inspectorView = embeddableControl.Item2;

inspector.Load(table, oid); ---------------------> failing here on load with null reference exception
 
foreach (var attribute in inspector)
       inspectorProvider.IsVisible(attribute);

 

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=ArcGIS.Desktop.Editing
StackTrace:
at ArcGIS.Desktop.Editing.EditUtil.CallSynchronous(Func`1 f, Boolean validate)

0 Kudos
NarelleChedzey
Esri Contributor

Sorry.  You also need to override an additional method in your implementation of the InspectorProvider.   Add the override for the AttributesOrder.   See the code snippet below. 

Also note that your add-in does not need to iterate through the attributes calling the IsVisible method after having loaded it.  The internal Pro code of the inspector control code calls the InspectorProvider methods.   All the add-in needs to do is create the inspector from your provider, create the embeddable control and then load the row. 

 

Narelle

  internal class CustomProvider : InspectorProvider
  {
    public override bool? IsVisible(Attribute attr)
    {
      if (attr.FieldName == "POP1990")
        return false;

      return true;
    }

    public override IEnumerable<Attribute> AttributesOrder(IEnumerable<Attribute> attrs)
    {
      return attrs;
    }
  }