Select to view content in your preferred language

How do I subscribe a StandaloneTable to a RowCreatedEvent?

148
2
Jump to solution
4 weeks ago
succip
by
Occasional Contributor

Hello,

We have a variety of datasets in our SDE that need fields auto-populated when a feature's created. My current implementation works fine for FeatureLayers because I can access the Table object when new map views are accessed. I work through all the FeatureLayers in the Map's TOC and subscribe them to events as needed. Unfortunately for StandaloneTables I can't directly subscribe them because they can't be converted to a Table object. Is there any way around this?

Any help is greatly appreciated. My current implementation is as follows:

Module1.cs:

 

 

        protected static void OnActiveMapViewChangedEvent(ActiveMapViewChangedEventArgs args)
        {
            if (MapView.Active != null)
            {
                EditorExtension.UnregisterRowEvents();
                foreach (FeatureLayer layer in MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
                {
                    EditorExtension.RegisterLayerEvents(layer);
                }

                foreach(StandaloneTable standaloneTable in MapView.Active.Map.GetStandaloneTablesAsFlattenedList())
                {
                    EditorExtension.RegisterStandaloneTableEvents(standaloneTable);
                }
            }
        }

 

 

EditorExtension.cs:

 

 

        public static void RegisterStandaloneTableEvents(StandaloneTable standaloneTable)
        {
            QueuedTask.Run(() =>
            {
                MapMember mapMember = standaloneTable as MapMember;
                CIMStandardDataConnection cimDataConnection = mapMember.GetDataConnection() as CIMStandardDataConnection;
                if (cimDataConnection.WorkspaceConnectionString.Contains("SDE.DEFAULT"))
                {
                    _rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable)); // ERROR: cannot convert standalonetable to table
                }
            });
        }

 

 

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

Hi,

StandaloneTable has method GetTable() witch returns table object.

_rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable.GetTable())); 

View solution in original post

2 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

StandaloneTable has method GetTable() witch returns table object.

_rowCreatedTokens.Add(RowCreatedEvent.Subscribe(OnRowCreatedEvent, standaloneTable.GetTable())); 
succip
by
Occasional Contributor

Oh geez of course, I even do this with the FeatureLayers. One of those days I guess!

Thank you so much for your help. Marked as solution. 

0 Kudos