AnsweredAssumed Answered

update attribute value and refresh tablecontrol

Question asked by vteyesriaustralia-com-au-esridist Employee on Oct 6, 2019
Latest reply on Oct 7, 2019 by taungesriaustralia-com-au-esridist

Hi,

 

ProGuide TableControl · Esri/arcgis-pro-sdk Wiki · GitHub 

 

I am following this guide. On click of a button, I am attempting to change a attribute value and then save that value in the featureClass and update the tableControl. However, the save seem to be locking the UI thread and the table doesn't updated, the refresh icon just keeps spinning. If I close the pane and open it again, the table is updated.

 

I have to use featureclass not not featurelayer as the layer I am updating most likely will not be added to the active map. Would anyone be able to advise?

 

 

 

public ICommand AddToMapCommand
        {
            get
            {
                if (_addToMapCommand == null)
                {
                    _addToMapCommand = new RelayCommand(() =>
                    {
                        //var oid = _tableControl.GetObjectIdAsync(_tableControl.ActiveRowIndex).Result;
                      

                        QueuedTask.Run(() =>
                        {
                            IReadOnlyList<long> oids = _tableControl.GetSeletedObjectIds();

                            using (Geodatabase geodatabase = new Geodatabase(new DatabaseConnectionFile(new Uri(@"D:\SDE connection\LEA-304867.sde"))))
                            {
                                using (FeatureClass featClass = geodatabase.OpenDataset<FeatureClass>("arcgis.DBO.polygonfeaturelayer"))
                                {
                                    EditOperation editOperation = new EditOperation();
                                    editOperation.Callback(context => {
                                        QueryFilter queryFilter = new QueryFilter
                                        {
                                            ObjectIDs = oids
                                        };

                                        using (RowCursor cursor = featClass.Search(queryFilter, false))
                                        {
                                            while (cursor.MoveNext())
                                            {
                                                using (Feature f = (Feature)cursor.Current)
                                                {
                                                    f["NAME"] = "Y";
                                                    f.Store();
                                                }
                                            }
                                        }
                                    }, featClass);

                                    bool success = editOperation.Execute();
                                    if (success)
                                    {
                                        Project.Current.SaveEditsAsync();
                                        this._tableControl.Refresh();

                                    }
                                    if (!success) throw new Exception(editOperation.ErrorMessage);

                                }
                            }                           
                        });

                    });
                }
                return _addToMapCommand;
            }
        }

Outcomes