2

I am trying to extend the inbuilt Select widget in the ArcGIS Web AppBuilder for Desktop using dojo. According to the documentation by ESRI we always inherit the 'dijit/_WidgetBase' module to create the custom widget.

define(['dojo/_base/declare', 'jimu/BaseWidget'],
function(declare, BaseWidget) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([BaseWidget], {
    // Custom widget code goes here 
    baseClass: 'jimu-widget-mywidget'
  });
});

Since I wanted the inherit he select widget I changed the code to the following:

define(['dojo/_base/declare', 'widgets/Select/Widget'],
function(declare, Select) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([Select], {
    baseClass: 'jimu-widget-selectlsa',
    startup: function() {
      this.inherited(arguments);
      console.log("tesiting")
    }  
  });
});

After copying all the HTML and CSS content from the default Select widget's to my custom widget's HTML and CSS the custom Select widget works fine.

Since I have inherited the default widget's Widget.js file I am able to call functions of the default widget form my custom widget.

However, in the default widget, there is one more file named SelectableLayerItem.js which has a method name _showActions. I tired adding the following code to access the _showActions method in the SelectableLayerItem.js file:

define(['dojo/_base/declare', 'widgets/Select/Widget','widgets/Select/SelectableLayerItem'],
function(declare, Select, SelectableLayerItem) {
  //To create a widget, you need to derive from BaseWidget.
  return declare([Select, SelectableLayerItem], {
    baseClass: 'jimu-widget-selectlsa',
    startup: function() {
      this.inherited(arguments);
      console.log("tesiting")
    },  
    _showActions: function(){
        //overwrite
    }
  });
});

After running the application, the application runs without any error in the console. However, my custom widget is not able to overwrite the _showActions method in the SelectableLayerItem.js file.

Instead of calling the overwritten method it always calls the default SelectableLayerItem.js's _showActions method.

How can I inherit multiple modules and access their methods independently?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.