Webappbuilder Customizing Widget templates
by Li Yuanxiang
- to the copy under \\widgets\samplewidgets directory customwidgettemplate file and rename it to mywidget
- Sets the class name of the widget. Open Widget.js in the mywidget directory and change baseclass to
baseclass: ' jimu-widget-mywidget ' as
- Customize the UI interface for widgets. You can add an interface for its widgets in the widget.html file. You can try adding the following code to this HTML page.
- Register your custom widget with your app. Open A stemapp/sample-configs file, locate widgetpool->widgets , Add a node content, and then save the file
- Test widget. Open the Http://[your host Name:3344]/webappviewer/?config=sample-configs/config-demo.json Click the icon and the icon appears, and the result is as follows
- Let widgets become more flexible with
A. Open mywidget config.json file, Add json structure text to Chajian, as follows
B. Change the original widget.html page code to allow it to read directly the configuration key variable
c. Open the test connection for step 5th to view the modified content. The content of the widget becomes the variable corresponding to the config file.
 
- Css/style.css file, add css code into the file as shown in:
- Access Map
- Open the Widget.js file and delete the comment for the startup function
- Modify the Widget.html page code and add the map ID attribute, as
- Re-refresh the page to see the ID of the map space being realistic.
- The end result is that the ID of the map control in the app is read
- Internationalization Support
You can write a configuration file to fit multiple languages. For example, the plugin used earlier is a hint in English that the "This is my widget" and "This is configurable" can be written by Mywidget Folder configuration file to implement localization in Chinese.
- Open nls/strings.js file, add the following code
- in the In the nls directory Create subfolders ZH-CN,
- Copy the String.js to the ZH-CN folder
- Modify The contents of the Zh-cn/strings.js file are as follows
- Modify the contents of the widget.html to read the configuration code, as
- Re-refresh the page to see the configuration in Chinese. Effects such as
- Deploying Widgets
- Open the manifest.json file, change properties inside, such as name , author , description name widget The folder name is the same.
You can see a description of the URL https://developers.arcgis.com/web-appbuilder/guide/widget-manifest.htm for each of the specific properties.
- Copy the Mywidget folder to \stemapp\widgetsfolder, startnode. JS (The fastest Hong Kong-style is open directlyWebappbuiliderfolder under theStart.batfile), enterHttp://[your host Name:3344]/webappbuilder, so that when usingWebappbuilderWhen you create an app, you can use a customWidgetsup. When the widget is selected, a defined plug-in will appear
Webappbuilder Customizing Widget templates