AnsweredAssumed Answered

Query widget : attribute edit

Question asked by helenchu on Sep 28, 2016
Latest reply on Sep 29, 2016 by helenchu

Robert Scheitlin, GISP

Hi Robert,

I'm sorry if I take too much of your time being back and forth on this Edit subject but I couldn't do it without your help and I think I'm now pretty close to getting that function work for my need.  

With my stacked accounts issue:

1/  Edit from attribute table: Success!  Thank you!

I finally can work around by populating the Edit popup only, then double click on the attribute button to open the attribute edit window.  By doing this 1 extra click, the attribute edit popup always populate the account associated with the selected record from attribute table.  My users can live with that.

I commented out part of your codes that use feature.geometry -> it returns all points.  

 

if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if(widgetCfg){
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function(editWidget){
editWidget.disableWebMapPopup();
setTimeout(lang.hitch(this, function(){
var showEvent = {};

// commented out to disable attribute popup
      // var featurePoint;
      // if(result[0].geometry.type === 'point') {
      // featurePoint = result[0].geometry;
      // } else {
      // featurePoint = result[0].geometry.getExtent().getCenter();
      // }

      //console.info(featurePoint);
      //showEvent.mapPoint = featurePoint;
      //showEvent.graphic = result[0];
editWidget.reClickMap(showEvent);
}), 500);
}));
}
}
//end

 

2/  Edit from Query result: Still struggle!

I copied the above codes but it didn't give me the same behavior.  I still got the Edit popup however the attribute button on that window is inactive (from both query result window and attribute window).  I must have missed something.

 

In widgets/Query/SingleQueryResult.js

 

if(def){
def.then(lang.hitch(this, function(){
if(typeof this.map.infoWindow.setFeatures === 'function'){
this.map.infoWindow.setFeatures([feature]);
}
if(typeof this.map.infoWindow.reposition === 'function'){
this.map.infoWindow.reposition();
}

/*start edits*/
//this.map.infoWindow.show(centerPoint);
if (this.wManager) {
var widgetCfg = this._getWidgetConfig('Edit');
if (widgetCfg) {
this.wManager.triggerWidgetOpen(widgetCfg.id).then(lang.hitch(this, function (widget) {
setTimeout(lang.hitch(this, function () {
var showEvent = {}; //new

//change to this: populate Edit 
editWidget.reClickMap(showEvent);
}), 500);
//end

//how it was before
   var mpPt = feature.geometry;
   var scrPt = this.map.toScreen(mpPt);
   this.map.emit("click", { bubbles: true, cancelable: true, screenPoint: scrPt, mapPoint: mpPt });
   }), 1000);
//end

}));
}
}

 

 

}));
}
}
},

/*Added the new support function*/
_getWidgetConfig: function (widgetName) {
var widgetCnfg = null;
array.some(this.wManager.appConfig.widgetPool.widgets, function (aWidget) {
if (aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
if (!widgetCnfg) {
/*Check OnScreen widgets if not found in widgetPool*/
array.some(this.wManager.appConfig.widgetOnScreen.widgets, function (aWidget) {
if (aWidget.name == widgetName) {
widgetCnfg = aWidget;
return true;
}
return false;
});
}
return widgetCnfg;
},
/* end new support function*/

_hideInfoWindow:function(){
if(this.map && this.map.infoWindow){
this.map.infoWindow.hide();
if(typeof this.map.infoWindow.setFeatures === 'function'){
this.map.infoWindow.setFeatures([]);
}
}
},

 

 

 

 

Outcomes