TransWikia.com

In ArcGIS Web appbuilder widget, how can i use a variable what is declared in another widget file?

Geographic Information Systems Asked on September 18, 2020

In Edit widget, i modified the RelatedRecordsEditor.js to automatically upload input fields with data like webMapId.

        var mapid=dijit.byId("dijit_form_ValidationTextBox_1").attr("value");
        console.log(mapid);
        var webMapId = this.map.itemInfo.item.id; //this is not working, only in widget.js
        var update = mapid.replace(mapid, webMapId);
        console.log(res);
        dojo.byId('dijit_form_ValidationTextBox_1').value = update;
      }); 

But there is no ‘map’ declared in this file, only in widget.js. How Can I reach that variable from RelatedRecordsEditor.js? Or how can I declare it? I tried:

define(['esri/map'] function(map)
        var map = this.map;
        console.log(map);
--->undefined

Or how can i use widges.js’s map object in this js?

One Answer

In RelatedRecordsEditor.js use this._editWidget.map to access the map object from widget.js

See how the this is attributed to _editWidget in the process of intstantiating relatedRecordsEditor in widget.js

// instantiate relatedRecordsEditor in widget.js

  this._relatedRecordsEditor = new RelatedRecordsEditor({
   originalFeature: feature,
   editorATI: this.editor.attributeInspector,
   tableInfosParam: this.layerInfosParamClone.concat(this.tableInfosParamClone),
   nls: lang.mixin(lang.clone(this.nls), window.jimuNls.common),

   // Use this._editWidget to access proporties and methods in the widget.js script from your relatedRecordsEditor.js

   _editWidget: this

            });

This way you can acces the appConfig, config and other properties of the widget.js from other script parts.

Answered by Mehretab on September 18, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP