Retrieve table cell value from context menu

189
2
Jump to solution
08-19-2020 02:15 PM
MarvisKisakye1
Occasional Contributor

I have inserted a custom button (FilterRows) into the right click context menu of a table cell as below.

<updateModule refID="esri_editing_EditingModule">
      <menus>     
        <updateMenu refID="esri_editing_tableCellContextMenu">
          <insertButton refID="FilterRows" separator="true" insert="after"
               placeWith="esri_editing_tableCopyCellButton" />
        </updateMenu>       
      </menus>
    </updateModule>   

I need to retrieve the value of the cell that the user right clicked on. I suspect that I need to retrieve the TableControl that the user clicked on and retrieve the cell value that way. But how do I retrieve the TableControl? Uma HaranoWolfgang Kaiser

0 Kudos
1 Solution

Accepted Solutions
UmaHarano
Esri Regular Contributor

Hi,

Here is a code snippet you can use to retrieve the values.

public static Task<object> ActiveCellContents()
    {
      if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane)
      {
        var mapMember = tablePane.MapMember;
        var oid = tablePane.ActiveObjectID;
        if (oid.HasValue && oid.Value != -1 && mapMember != null)
        {
          var activeField = tablePane.ActiveColumn;
          return QueuedTask.Run<object>(() =>
          {
            // TODO: Use core objects to retrieve record and get value
            
            return null;
          });
        }
      }

      return Task.FromResult<object>(null);
    }

Thanks

Uma

View solution in original post

0 Kudos
2 Replies
UmaHarano
Esri Regular Contributor

Hi,

Here is a code snippet you can use to retrieve the values.

public static Task<object> ActiveCellContents()
    {
      if (FrameworkApplication.Panes.ActivePane is ITablePane tablePane)
      {
        var mapMember = tablePane.MapMember;
        var oid = tablePane.ActiveObjectID;
        if (oid.HasValue && oid.Value != -1 && mapMember != null)
        {
          var activeField = tablePane.ActiveColumn;
          return QueuedTask.Run<object>(() =>
          {
            // TODO: Use core objects to retrieve record and get value
            
            return null;
          });
        }
      }

      return Task.FromResult<object>(null);
    }

Thanks

Uma

0 Kudos
MarvisKisakye1
Occasional Contributor

Brilliant! Thank you!

0 Kudos