Select to view content in your preferred language

Change the selected item in the Attribute pane's tree view

2869
13
05-03-2023 11:58 PM
GISNewbieDev
Emerging Contributor

 

Hi,

I am facing a problem with the current selection item in the attributes pane's tree view. The use case is let us suppose we already have some features or standalone tables selected in the attribute pane. And in my case I have a custom dock pane from where I am adding new row or rows in my standalone table. So, in this case I am selecting that row at the end of my edit operation which will lead to that item to get added in the attribute pane. But the problem is that newly added item of my standalone table is not getting selected in the attribute pane. On contrary its getting resetted. How resetted? If before my operation if I have selected multiple features of same type and manually selected third item from that type. After my operation selected item will not be there but to the first item of that type(even when you are moving from attribute pane to somewhere else it is resetting again).

But in my case I wanted the selected item to change to my newly added item. And how to keep the selected item there only till any other operation(meaning any other new item is added)?

For selection I used below line:

standaloneTable.Select(new QueryFilter { ObjectIDs = new List<long> { newId } }, SelectionCombinationMethod.Add);

I have used all the SelectionCombinationMethods also but still the result is same.

 

@Wolf @UmaHarano @GKmieliauskas @MichaelHirschheimer  @NarelleChedzey 

Tags (1)
0 Kudos
13 Replies
GISNewbieDev
Emerging Contributor

1. I am not sure if I can share the database model over here since it is a private code. But I have already confirmed all the database table’s columns and its datatype matches the entity class.

2. And did u got my 2nd requirement? Sorry for the very long description.

@Wolf 

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Regarding 1.

There are many opportunities for an edit operation to fail: Attribute rules, relationships, domain values, etc.   I would suggest you start your debugging session with as simple as possible (i.e. only add an item with the geometry set) and if that works you can add more fields to find out when it fails.  If the simple case doesn't work your geometry might be bad, or there are domain value requirements with no default values, or other attribute rules.  Without code and data sample i can't help.

Regarding 2:

I am still not 100% sure what you're trying to accomplish, but i think you want to maintain the current feature selection (from the map) and only customize the row selection (from a table) that is done via your custom UI.  If that's the case, then the solution i listed above will do the job as it doesn't affect any existing feature selection.

 

    // load the first selected feature into the inspector using the first OID from the list of object IDs
    var mapMember = firstSelectionSet.Key;
    var oid = firstSelectionSet.Value[0];
    inspector.Load(mapMember, oid);

    //Create new feature from an existing inspector (copying the feature)
    var createOp = new EditOperation
    {
      Name = "Copy first selected row",
      SelectNewFeatures = false
    };
    var rowToken = createOp.Create(inspector.MapMember, inspector);  // inspector.ToDictionary(a => a.FieldName, a => a.CurrentValue)
    if (createOp.IsEmpty)
    {
      MessageBox.Show($@"Record oid: {oid} in table: [{mapMember.Name}] was not duplicated");
    }
    else
    {
      var result = createOp.Execute(); //Execute and ExecuteAsync will return true if the operation was successful and false if not
      if (!result)
        MessageBox.Show($@"Copying record oid: {oid} in table: [{mapMember.Name}] failed: [{createOp.ErrorMessage}]");
      else
      {
        var newOid = rowToken.ObjectID.Value;
        MessageBox.Show($@"New record oid: {newOid} in table: [{mapMember.Name}]");
        // now add this record to the existing selection
        (mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);
      }
    }

The key to get the NEW row into the selection are these lines:

1. "SelectNewFeatures = false"

2. "(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { newOid } }, SelectionCombinationMethod.Add);"

Now as the code says this will add the new row to the existing selected rows of my custom UI code, if i want to remove any old rows i can simply call:

"(mapMember as StandaloneTable).Select(new QueryFilter() { ObjectIDs = new long[] { oldOid } }, SelectionCombinationMethod.Subtract)

Or if you want to clear all records for the table that are selected in your custom UI before you make a new selection you can simply call the following before the new selection code is executed:

"(mapMember as StandaloneTable).ClearSelection()"

You cannot control which row is hightlighted in the Attribute tree view (the highlighted row is used for detail display).

 

0 Kudos
GISNewbieDev
Emerging Contributor

No in my case what I want is if there is already something selected from the map which is now in the attribute pane and then after that if I am trying to select from my custom UI besides that being shown in the attribute pane I also want the new selection should be the highlighted one in the tree view by moving the highlighted/current selection from the earlier one.

 

> Attribute Tree view

    > Some selection from the map Right now this is selected one in the tree and is highlighted as well

 

After that I did some selection from the custom UI, attribute pane should get updated

> Attribute Tree view

    > Some selection from the map

    > New selection from my custom UI     Now this is the selected and highlighted one

So the highlight moved from the previous one to this one.

 

@Wolf @GKmieliauskas 

0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

As @Wolf  wrote, "You cannot control which row is hightlighted in the Attribute tree view (the highlighted row is used for detail display)". So you need to create your own Attribute dockpane and then you can control your tree items as you want.