1. Get started

  2.  Welcome
  3.  Get started
  4.  Run as a Windows service
  5.  Build your first app
  6.  Requirements
  7.  Accessibility support
  8.  Development overview
  9.  About release versions
  10.  What's new
  11.  Frequently asked questions
  12. Working with apps

  13.  Home page
  14.  Create or import an app
  15.  Edit and launch an app
  16.  Choose a theme
  17.  Select a map or scene
  18.  Add widgets
  19.  Widgets overview
  20.  Configure app attributes
  21.  Preview apps on smaller screens
  22.  Export as a template
  23.  Edit or preview template
  24.  Use URL parameters
  25.  Upgrade apps
  26. Configure 2D widgets

  27.  About widget
  28.  Add Data widget
  29.  Analysis widget
  30.  Attribute Table widget
  31.  Batch Attribute Editor widget
  32.  Basemap Gallery widget
  33.  Bookmark widget
  34.  Business Analyst widget
  35.  Chart widget
  36.  Controller widget
  37.  Coordinate widget
  38.  Coordinate Conversion widget
  39.  Cost Analysis widget
  40.  Data Aggregation widget
  41.  Directions widget
  42.  Distance and Direction widget
  43.  District Lookup widget
  44.  Draw widget
  45.  Edit widget
  46.  Emergency Response Guide widget
  47.  Extent Navigate widget
  48.  Filter widget
  49.  Full Screen widget
  50.  Geocoder widget
  51.  GeoLookup widget
  52.  Geoprocessing widget
  53.  Grid Overlay widget
  54.  Gridded Reference Graphic widget
  55.  Group Filter widget
  56.  Image Measurement widget
  57.  Home Button widget
  58.  Incident Analysis widget
  59.  Infographic widget
  60.  Info Summary widget
  61.  Layer List widget
  62.  Legend widget
  63.  Measurement widget
  64.  My Location widget
  65.  Near Me widget
  66.  Network Trace widget
  67.  Oblique Viewer widget
  68.  Overview Map widget
  69.  Parcel Drafter widget
  70.  Print widget
  71.  Public Notification widget
  72.  Query widget
  73.  Related Table Charts widget
  74.  Report Feature widget
  75.  Reviewer Dashboard widget
  76.  Scalebar widget
  77.  Screening widget
  78.  Search widget
  79.  Select widget
  80.  Share widget
  81.  Situation Awareness widget
  82.  Smart Editor widget
  83.  Splash widget
  84.  Stream widget
  85.  Suitability Modeler widget
  86.  Summary widget
  87.  Swipe widget
  88.  Threat Analysis widget
  89.  Time Slider widget
  90.  Visibility widget
  91.  Zoom Slider widget
  92. Configure 3D widgets

  93.  3DFx widget
  94.  About widget
  95.  Basemap Gallery widget
  96.  Compass widget
  97.  Coordinate widget
  98.  Daylight widget
  99.  Full Screen widget
  100.  Home Button widget
  101.  Layer List widget
  102.  Legend widget
  103.  Measurement widget
  104.  My Location widget
  105.  Navigate widget
  106.  Search widget
  107.  Share widget
  108.  Slides widget
  109.  Splash widget
  110.  Zoom Slider widget
  111. Widget development

  112.  Get started
  113.  Naming conventions
  114.  In-panel and off-panel widgets
  115.  Deploy your widget
  116.  Required files
  117.  Widget manifest
  118.  Extend BaseWidget
  119.  Required properties
  120.  Define the template
  121.  Configure the Demo widget
  122.  Add i18n support
  123.  Make widgets user-friendly
  124.  Build your first app
  125.  Communication to app container
  126.  Widget properties
  127.  Make widgets responsive
  128.  Communication between widgets
  129.  Dojo dijit
  130.  Make widgets configurable in builder
  131.  Make widgets backward compatible
  132.  Create a controller widget
  133.  Widget life cycle
  134.  Add help for your widget
  135.  Create a feature action in your widget
  136.  Provide and consume data sources in widgets
  137.  Best practices for unit testing
  138. Theme development

  139.  Theme elements
  140.  Create a theme
  141. 3D development

  142.  3D development guide
  143. Sample code

  144.  Create a custom in-panel widget
  145.  Create a ListView widget
  146.  Create a custom widget using the Report dijit
  147.  Create a new theme
  148.  Create a new style for a theme
  149.  Create a new default layout
  150.  Create a nondefault layout
  151.  Create a new panel
  152.  Create a new layout widget
  153.  Create a controller widget
  154.  Create a feature action in your widget
  155.  Send a layer to the Attribute Table widget
  156.  Open multiple widgets simultaneously
  157.  Use other libraries
  158.  Change the URL of ArcGIS API for JavaScript
  159. Deployment

  160.  Deploy your app
  161.  Use proxy
  162.  Web-tier authentication
  163.  Custom widget and theme deployment
  164.  Upgrade custom widgets and themes
  165. Framework reference

  166.  CSS framework
  167.  FeatureActionManager class
  168.  FilterManager class
  169.  LayerInfo class
  170.  LayerInfos class
  171.  LayerNode class
  172.  LayerStructure class
  173.  PanelManager class
  174.  SelectionManager class
  175.  Utils class
  176.  WidgetManager class
  177. dijit

  178.  FeaturelayerChooserFromMap class
  179.  FeaturelayerServiceBrowser class
  180.  FeatureSetChooserForSingleLayer class
  181.  Filter class
  182.  ImageChooser class
  183.  ItemSelector class
  184.  LayerChooserFromMap class
  185.  RendererChooser class
  186.  Report class
  187.  SnapShot class
  188.  SymbolChooser class
  189. JSON reference

  190.  App configuration
  191.  Map configuration
  192.  Widget configuration
  193.  Widget pool configuration
  194.  Widget on-screen configuration
  195.  Panel configuration
  196.  Group configuration
  197.  DataSource configuration
  198.  About
  199.  Analysis
  200.  Attribute Table
  201.  Basemap Gallery
  202.  Bookmark
  203.  Chart
  204.  Coordinate
  205.  Directions
  206.  Draw
  207.  Edit
  208.  Full Screen
  209.  Geocoder
  210.  Geoprocessing
  211.  Controller
  212.  Home Button
  213.  Image Measurement
  214.  Infographic
  215.  Layer List
  216.  Legend
  217.  Loading Page
  218.  Measurement
  219.  My Location
  220.  Near Me
  221.  Oblique Viewer
  222.  Overview Map
  223.  Print
  224.  Query
  225.  Report Feature
  226.  Reviewer Dashboard
  227.  Scalebar
  228.  Search
  229.  Share
  230.  Splash
  231.  Stream
  232.  Swipe
  233.  Time Slider
  234.  Zoom Slider
  235. What's new archive

  236.  What's new in version 2.23
  237.  What's new in version 2.22
  238.  What's new in version 2.21
  239.  What's new in version 2.20
  240.  What's new in version 2.19
  241.  What's new in version 2.18
  242.  What's new in version 2.17
  243.  What's new in version 2.16
  244.  What's new in version 2.15
  245.  What's new in version 2.14
  246.  What's new in version 2.13
  247.  What's new in version 2.12
  248.  What's new in version 2.11
  249.  What's new in version 2.10
  250.  What's new in version 2.9
  251.  What's new in version 2.8
  252.  What's new in version 2.7
  253.  What's new in version 2.6
  254.  What's new in version 2.5
  255.  What's new in version 2.4
  256.  What's new in version 2.3
  257.  What's new in version 2.2
  258.  What's new in version 2.1
  259.  What's new in version 2.0
  260.  What's new in version 1.3
  261.  What's new in version 1.2
  262.  What's new in version 1.1

Create a ListView widget

This tutorial describes how to create a custom Web AppBuilder in-panel widget that does the following:

NoteNote:

The web map used in this tutorial contains a feature layer that has a thumbnail image for each feature.

Create a widget folder structure

You can either use the Widget Generator in this Web AppBuilder generator tool, or complete the following steps to create a simple widget as your starting point.

CautionCaution:

You may use the Web AppBuilder generator tool in this sample; however, it is not supported.

Steps:
  1. Make a copy of the Demo folder at path/to/WAB/client/stemapp/ widgets/samplewidgets.
  2. Paste it to the widgets under stemapp or (stemapp3d if you're developing a widget for 3D apps).
  3. Rename the folder ListView.
  4. In manifest.json, update the widget’s general information, such as the name and author. The value of the name field should be the same as the widget folder name, in this case, ListView. And in the nls folder, update the value of the _widgetLabel variable to ListView in the strings.js files (you can remove unused i18n folders as needed).

    NoteNote:
    See Add i18n support for more information on adding i18n support.

  5. Replace the widget icon.png file with a different image to use as the icon.
  6. Open Web AppBuilder and click New App.

    The ListView widget appears as a member of the widgets on the Choose Widget dialog box.

    ListView

The configuration page of the ListView widget now only has a sample text box.

Sample text

The UI of the widget contains some sample UI components.

Sample UI components

You will update these pages later in this tutorial.

Customize the settings page

For the ListView widget, the widget’s header text should be configurable. The list should be populated from a user-selected feature layer and allow the user to define which feature attributes to use to populate the list items.

Update the config.json file

The config.json file in a widget folder provides optional default settings to initialize a widget. You can configure these setting options.

In the following steps, the sample configuration that comes with the Demo widget will be removed, and a new attribute will be added to populate the header section of the widget:

Steps:
  1. Open config.json at path/to/WAB/client/stemapp/widgets/ListView.
  2. Replace everything with the following:

    {
    	"widgetHeaderText":"Please select a feature:"
    }
    

Update the settings (configuration) page UI

In the following steps, you will update the UI of the settings page by adding the following:

  • A text box to enter text for the header
  • A drop-down list to select a feature layer from the map
  • A set of drop-down lists to map attributes from the feature layer to UI elements

Steps:
  1. Open strings.js at path/to/WAB/client/stemapp/widgets/ListView/setting/nls.
  2. Remove configText and add the following attributes:

    define({
    	root: ({
    		headerText: "Set header text:",
    		selectLayerText: "Select a layer:",
    		pickAttributeText: "Map the following UI components to attributes:",
    		UIElementNames: {
    			thumbnail: "thumbnail",
    			title: "title"
    		}
      })
    });
    

  3. Open Setting.html at path/to/WAB/client/stemapp/widgets/ListView/setting.
  4. Replace the entire page with the following:

    <div>
    	<div>
    		<label>${nls.headerText}</label>
    		<input class="jimu-input" data-dojo-attach-point="headerTextNode">
    	</div>
    	<div>
    		<label>${nls.selectLayerText}</label>
    		<select data-dojo-type="dijit/form/Select" data-dojo-attach-point="layerSelect"></select>
    	</div>
    	<hr>
    	<h3>${nls.pickAttributeText}</h3>
    	<div>
    		<label>${nls.UIElementNames.thumbnail}</label>
    		<select data-dojo-type="dijit/form/Select" data-dojo-attach-point="thumbnailSelect"></select>
    	</div>
    	<div>
    		<label>${nls.UIElementNames.title}</label>
    		<select data-dojo-type="dijit/form/Select" data-dojo-attach-point="titleSelect"></select>
    	</div>	
    </div>
    

    NoteNote:

    The jimu-input class name is added to the text input to restyle its look. This class is provided by the Jimu CSS framework, which also provides CSS styles for other UI elements. You can view the .css files at path/to/WAB/client/stemapp/jimu.js/css for details. You can also preview some of the jimu UI components by going to the following local test pages:

    • CSS test: http://<server>[:port]/webappbuilder/stemapp/jimu.js/tests/test-css.html
    • Dijit test: http://<server>[:port]/webappbuilder/stemapp/jimu.js/demo/dijit.html

  5. Open Setting.js at path/to/WAB/client/stemapp/widgets/ListView/setting.
  6. Add the following classes to the array of class declarations:

    define([
      'dojo/_base/declare',
      'jimu/BaseWidgetSetting',
      'dojo/_base/lang',
      'dojo/_base/array',
      'dijit/_WidgetsInTemplateMixin',
      'jimu/LayerInfos/LayerInfos',
      'dijit/form/Select'
    ],
    function(declare, BaseWidgetSetting, lang, array, _WidgetsInTemplateMixin, LayerInfos) {
      return declare([BaseWidgetSetting, _WidgetsInTemplateMixin], {
      ...
      });
    });
    

  7. Change the baseClass value to jimu-widget-listview-setting.
  8. In the setConfig method, remove the sample code and add the following line of code to populate the header node with the default string defined in the nls folder at path/to/WAB/client/stemapp/widgets/ListView:

    setConfig: function(config){
          // Update header text
          this.headerTextNode.value = config.widgetHeaderText;
    },
    

    Get all the feature layer information from the map using the LayerInfos class from the Jimu framework, and populate the feature layer drop-down list as follows:

    setConfig: function(config){
          // Update header text
          this.headerTextNode.value = config.widgetHeaderText;
    
          // Get all feature layers from the map
          LayerInfos.getInstance(this.map, this.map.itemInfo)
          .then(lang.hitch(this, function(layerInfosObj) {
            var infos = layerInfosObj.getLayerInfoArray();
            var options = [];
            array.forEach(infos, function(info) {
              if(info.originOperLayer.layerType === 'ArcGISFeatureLayer') {
                options.push({
                  label: info.title,
                  value: info.id
                });
              }
            });
            this. layerSelect.set('options', options);
          }));
        },
    
  9. Attach an onChange event handler to the layerSelect dijit. When the selection in the layerSelect drop-down list changes, get a list of all attributes from the newly selected feature layer and use it to populate the attribute drop-down lists as follows:
    setConfig: function(config){
    ...
          // Get all feature layers from the map
          LayerInfos.getInstance(this.map, this.map.itemInfo)
    .then(lang.hitch(this, function(layerInfosObj) {
      ...
            this.layerSelect.set('options', options);
            this.layerSelect.on('change', lang.hitch(this, function(value) {
              var selectedLayer = layerInfosObj.getLayerInfoById(value);
              if(selectedLayer) {
                var fieldOptions = array.map(selectedLayer.layerObject.fields, function(field) {
                  return {
                    label: field.alias || field.name,
                    value: field.name
                  }
                });
                this.thumbnailSelect.set('options', fieldOptions);
                this.titleSelect.set('options', fieldOptions);
              }
    
            }));
          }));
        },
    
  10. Go to the getConfig method in the return section, remove configText, and add the following code:
    getConfig: function(){
          //WAB will get config object through this method
          return {
            widgetHeaderText: this.headerTextNode.value,
            layerId: this.layerSelect.get('value'),
            thumbnailField: this.thumbnailSelect.get('value'),
            titleField: this.titleSelect.get('value')
          };
        }
    

    These configurations will be consumed by the ListView widget to access the feature layer object from the map and update the list with the defined fields.

  11. Add CSS styles in the style.css file at path/to/WAB/client/stemapp/widgets/ListView/setting/css to style the settings page as follows:
    .jimu-widget-listview-setting > * {
      margin-bottom: 10px;
    }
    
    .jimu-widget-listview-setting label {
      display: inline-block;
      min-width: 150px;
      margin-right: 10px;
    }
    .jimu-widget-listview-setting h3 {
      color: #999;
      font-weight: normal;
      margin-bottom: 20px;
    }
    .jimu-widget-listview-setting hr {
      margin: 30px 0;
      border-style: solid;
      border-width: 0 0 1px 0;
      border-color: #ddd;
    }
    .jimu-widget-listview-setting .jimu-input,
    .jimu-widget-listview-setting .dijitSelect {
      width: 300px;
    }
    .jimu-widget-listview-setting .dijitSelect .dijitButtonContents {
      width: 100%;
    }
    

    The settings page now looks like the following:

    Settings page

Create the widget's HTML template

The sample widget used in this tutorial is a template-based Dojo widget that contains a widget.html file as its HTML structure. In this section, you will remove any unused sample code from widget.html, and add two DOM nodes for the following UI components:

  • Header
  • List

These components will be populated with live data in later sections.

Steps:
  1. Open path/to/WAB/client/stemapp/widgets/ListView/widget.html.
  2. Replace the content with the following HTML string:
    <div>
    	<div class="list-header" data-dojo-attach-point="headerNode"></div>
    	<div data-dojo-attach-point="ListNode"></div>
    </div>
    

Modify widget.js

Developing a Web AppBuilder widget is similar to developing a Dojo template widget. The widget.js file contains the basic widget life cycle methods, such as postCreate and startup, and additional methods customized for the Web AppBuilder environment, such as onOpen, onClose, and onMinimized. Visit the Widget life cycle page for details on the Web AppBuilder widget life cycle.

Set the widget's base class name

The baseClass property in the widget.js file is required. This string will be appended to the class attribute on the root HTML node of the widget when it is initialized. Multiple class names can be added by separating them with spaces. To rename baseClass to jimu-widget-listview, see the following:

baseClass: 'jimu-widget-listview',

Remove unused sample code

Remove the following line of code from the startup method:

this.mapIdNode.innerHTML = 'map id:' + this.map.id;

Now, the ListView pane appears empty in Web AppBuilder.

Empty ListView

Add a list UI component using dGrid OnDemandList

Visit the dGrid page and the OnDemandList on OnDemandList.

Steps:
  1. Add the following to the array of class declarations:
    define(['dojo/_base/declare',
    'jimu/BaseWidget',
    'dojo/_base/lang',
    'dojo/Deferred',
    'dgrid/OnDemandList',
    'dgrid/Selection',
    "dojo/store/Memory"],
    function(declare, BaseWidget,
      lang, Deferred,
      OnDemandList, Selection, Memory) {
        ...
      });
    });
    
  2. Declare a new method named getDataStore, which will return a dataset to populate the list. Add some sample data to test the widget as follows:
    getDataStore: function() {
          var def = new Deferred();
          // SAMPLE DATA
          var SAMPLEDATA = [{
            'id': 0,
            'title': 'Feature 1',
            'thumbnailImg': 'http://placehold.it/120x90'
          }, {
            'id': 1,
            'title': 'Feature 2',
            'thumbnailImg': 'http://placehold.it/120x90'
          }];
          def.resolve(new Memory({
            data: SAMPLEDATA
          }));
          return def;
        },
    
  3. Declare another method named createList, which consumes the data store returned from the getDataStore method and creates a new OnDemandList as follows:
    createList: function() {
          this.getDataStore().then(lang.hitch(this, function(datastore) {
            var list = new (declare([OnDemandList, Selection]))({
              'store': datastore,
              'selectionMode': 'single',
              'renderRow': lang.hitch(this, function (object, options) {
                return this._createListItem(object);
              })
            }, this.ListNode);
            list.startup();
          }));
        },
    
  4. Note that the _createListItem method is called when rendering rows for the dGrid list. To create this method, do the following:
    _createListItem: function(featureObj) {
          var listItemRoot = document.createElement('DIV');
          listItemRoot.className = 'list-item';
          if(featureObj) {
            var thumbnailImgWrapper, thumbnailImg, listItemTitle;
            // Create thumbnail
            if(featureObj.thumbnailImg) {
              thumbnailImgWrapper = document.createElement('div');
              thumbnailImgWrapper.className = 'thumbnail-wrapper';
              thumbnailImg = document.createElement('img');
              thumbnailImg.src = featureObj.thumbnailImg;
              thumbnailImgWrapper.appendChild(thumbnailImg);
              listItemRoot.appendChild(thumbnailImgWrapper);
            }
            // Create title
            if(featureObj.title && typeof featureObj.title === 'string') {
              listItemTitle = document.createElement('H4');
              listItemTitle.innerHTML = featureObj.title;
              listItemRoot.appendChild(listItemTitle);
              if(thumbnailImg)
                thumbnailImg.alt = featureObj.title;
            }
          } else {
            listItemRoot.innerHTML = 'NO DATA AVAILABLE';
          }
    
          return listItemRoot;
        },
    
  5. Call the createList method from postCreate.
    postCreate: function() {
      this.inherited(arguments);
      console.log('postCreate');
      
      this.createList();
    },
    
  6. Restart Web AppBuilder and re-add the ListView widget to the app. The following two sample results appear in the list:

    ListView re-added

    Now you have the major pieces of the widget in place.

Read configuration and update UI elements

In this section, you'll read the configuration from the settings page and populate the list with real data.

Steps:
  1. Update headerNode in the postCreate method.
    postCreate: function() {
          this.inherited(arguments);
          console.log('postCreate');
    
          this.headerNode.innerHTML = this.config.widgetHeaderText;
          this.createList();
        },
    
  2. Populate the list with data from the feature layer.
    1. Get the feature layer from the map.
      postCreate: function() {
            this.inherited(arguments);
            console.log('postCreate');
      
            this.headerNode.innerHTML = this.config.widgetHeaderText;
            this.featureLayer = this.map.getLayer(this.config.layerId);
            this.createList();
          },
      
    2. Add the query functionality from ArcGIS API for JavaScript to the widget.

      define(['dojo/_base/declare',
      'jimu/BaseWidget',
      'dojo/_base/lang',
      'dojo/Deferred',
      'dgrid/OnDemandList',
      'dgrid/Selection',
      "dojo/store/Memory",
      "esri/tasks/query"],
      function(declare, BaseWidget,
        lang, Deferred,
        OnDemandList, Selection, Memory,
        Query) {
        ...
      });
      });
      

    3. In the getDataStore method, get the selected feature layer from the map using the configuration information.

      getDataStore: function() {
            var def = new Deferred();
            var layer = this.map.getLayer(this.config.layerId);
        ...
      },
      

    4. Query all features from the feature layer.

      getDataStore: function() {
            ...
            // Query features
            var query = new Query();
            query.returnGeometry = false;
            query.outFields = ["*"];
            query.where = '1=1';
            layer.queryFeatures(query, lang.hitch(this, function(featureSet) {
              
      }));
      ...
      },
      

    5. Remove the sample data and use the returned feature set instead.

      1. Remove the SAMPLEDATA variable.
      2. Remap the feature data to a new array named featureSetRemapped, and use it to create the data store.
        getDataStore: function() {
              ...
        layer.queryFeatures(query, lang.hitch(this, function(featureSet) {
          var featureSetRemapped = [];
                for(var index in featureSet.features) {
                  var feature = featureSet.features[index];
                  featureSetRemapped.push({
                    'id': feature.attributes[this.featureLayer.objectIdField],
                    'title': feature.attributes[this.config.titleField],
                    'thumbnailImg': feature.attributes[this.config.thumbnailField]
                  });
                }
        
                def.resolve(new Memory({
                  data: featureSetRemapped
                }));
              }));
        
              return def;
            },
        

The ListView widget now shows the correct results from the configured feature layer without any applied styles.

ListView correct results

Add CSS styles to change the widget's look

Steps:
  1. Open the style.css file from path/to/WAB/client/stemapp/widgets/ListView /css and add the following CSS styles:
    .jimu-widget-listview {
      background-color: #f1f1f1;
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      overflow: auto;
    }
    .jimu-widget-listview .dgrid-list {
      height: auto;
      border: 0;
      position: absolute;
      top: 35px;
      left: 0;
      right: 0;
      bottom: 0;
    }
    .jimu-widget-listview .dgrid-scroller {
      padding: 10px 10px;
      overflow: auto;
    }
    .jimu-widget-listview .dgrid-row {
      background: #fff;
      border: 1px solid #e1e1e1;
      padding: 10px 10px;
      margin-bottom: 10px;
    }
    .jimu-widget-listview .list-item {
      -moz-transition: all, 0.2s, ease-out;
      -o-transition: all, 0.2s, ease-out;
      -webkit-transition: all, 0.2s, ease-out;
      transition: all, 0.2s, ease-out;
    }
    .jimu-widget-listview .list-item:after {
      content: "";
      display: table;
      clear: both;
    }
    .jimu-widget-listview .list-item h4 {
      color: #00a8e1;
      line-height: 2;
      letter-spacing: 1px;
      margin: 0 15px;
    }
    .jimu-widget-listview .list-item .thumbnail-wrapper {
      float: left;
      width: 80px;
      height: 50px;
      margin-right: 15px;
      overflow: hidden;
    }
    .jimu-widget-listview .list-item .thumbnail-wrapper img {
      width: 100%;
    }
    .jimu-widget-listview .list-item.dgrid-selected {
      border: 1px solid #00a8e1;
      -moz-box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
      -webkit-box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
      box-shadow: 0 4px 4px rgba(0, 0, 0, 0.2);
      position: relative;
      z-index: 1;
      cursor: default;
    }
    .jimu-widget-listview .list-item.simple.dgrid-selected {
      margin-bottom: 0;
    }
    .jimu-widget-listview .list-header {
      padding: 10px;
      padding-bottom: 0;
      font-size: 14px;
      overflow: hidden;
      *zoom: 1;
    }
    .jimu-widget-listview .list-header > h3 {
      margin: 0;
      margin-top: 4px;
      padding: 0 10px;
      float: left;
      font-weight: normal;
      text-transform: uppercase;
      color: #ed1c25;
    }
    .jimu-widget-listview .list-header > h3 strong {
      margin: 0 5px;
    }
    .jimu-widget-listview .list-header label {
      color: #93999e;
    }
    
  2. Refresh Web AppBuilder and add the ListView widget again to the app. The widget now has the new CSS styles applied.

    New CSS style

Communicate with the map

You'll now see how a widget can communicate with the map by adding the ability to highlight map graphics when a row in the list is selected. Learn how to access a map.

Steps:
  1. Go to the createList method and add an onclick event handler to the rows of the list.
    createList: function() {
          this.getDataStore().then(lang.hitch(this, function(datastore) {
            ...
            list.startup();
            list.on('.dgrid-row:click', lang.hitch(this, function(evt) {
            }));
          }));
        },
    
  2. Use list.row(evt) to access the feature data from the selected row, query the feature layer to get the selected feature from the map, and bring it to the center of the map.
    createList: function() {
          this.getDataStore().then(lang.hitch(this, function(datastore) {
            ...
            list.startup();
            list.on('.dgrid-row:click', lang.hitch(this, function(evt) {
              var row = list.row(evt);
              var query = new Query();
              query.objectIds = [row.data.id];
              this.featureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, lang.hitch(this, function(result) {
                if (result.length) {
                  var feature = result[0],
                  newMapCenter,
                  geometry = feature.geometry,
                  extent = geometry.getExtent(),
                  shape = feature.getShape();
                  if(extent && extent.getCenter) {
                    newMapCenter = extent.getCenter(); // polygon & polyline
                  } else {
                    newMapCenter = geometry; // point
                  }
                  this.map.centerAt(newMapCenter); // move to the feature
                  if(shape) shape.moveToFront(); // move the feature to front
                }
              }));
            }));
          }));
        },
    
  3. Highlight the selected feature on the map.
    1. Add the following to the array of class declarations:

      define(['dojo/_base/declare',
      ...
      "esri/tasks/query",
      "esri/symbols/SimpleMarkerSymbol",
      "esri/symbols/SimpleLineSymbol",
      "esri/symbols/SimpleFillSymbol"
      ],
      function(declare, BaseWidget,
        lang, Deferred,
        OnDemandList, Selection, Memory,
        Query, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol) {
          ...
        });
      });
      

    2. In PostCreate, add code to the custom feature layer’s highlight symbol based on its geometry type.

      postCreate: function() {
            ...
      
            this.featureLayer = this.map.getLayer(this.config.layerId);
      
            var highlightSymbol;
            switch(this.featureLayer.geometryType) {
              case 'esriGeometryPoint':
              highlightSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 20, null, '#e74c3c');
              break;
              case 'esriGeometryPolyline':
              highlightSymbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, '#e74c3c', 3);
              break;
              case 'esriGeometryPolygon':
              highlightSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, '#fff', 2),
                '#e74c3c');
              break;
            }
            this.featureLayer.setSelectionSymbol(highlightSymbol);
      
            this.createList();
          },