Greetings,
In WAB 2.3, using the add data widget, is there a way to set it to sort by title as the default? Any assistance would be greatly appreciated!
Jason
Jason,
You need to make changes in two files:
[install dir]\server\apps\[app#]\widgets\AddData\search\SortOptions.js line 31:
<SPAN class="comment token">///////////////////////////////////////////////////////////////////////////</SPAN> <SPAN class="comment token">// Copyright © 2016 Esri. All Rights Reserved.</SPAN> <SPAN class="comment token">//</SPAN> <SPAN class="comment token">// Licensed under the Apache License Version 2.0 (the "License");</SPAN> <SPAN class="comment token">// you may not use this file except in compliance with the License.</SPAN> <SPAN class="comment token">// You may obtain a copy of the License at</SPAN> <SPAN class="comment token">//</SPAN> <SPAN class="comment token"><SPAN>// </SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fwww.apache.org%2Flicenses%2FLICENSE-2.0" target="_blank">http://www.apache.org/licenses/LICENSE-2.0</A></SPAN> <SPAN class="comment token">//</SPAN> <SPAN class="comment token">// Unless required by applicable law or agreed to in writing, software</SPAN> <SPAN class="comment token">// distributed under the License is distributed on an "AS IS" BASIS,</SPAN> <SPAN class="comment token">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</SPAN> <SPAN class="comment token">// See the License for the specific language governing permissions and</SPAN> <SPAN class="comment token">// limitations under the License.</SPAN> <SPAN class="comment token">///////////////////////////////////////////////////////////////////////////</SPAN> <SPAN class="token function">define</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">"dojo/_base/declare"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dojo/on"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dojo/dom-class"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"./SearchComponent"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dojo/text!./templates/SortOptions.html"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dojo/i18n!../nls/strings"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"dijit/form/Select"</SPAN> <SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>declare<SPAN class="punctuation token">,</SPAN> on<SPAN class="punctuation token">,</SPAN> domClass<SPAN class="punctuation token">,</SPAN> SearchComponent<SPAN class="punctuation token">,</SPAN> template<SPAN class="punctuation token">,</SPAN> i18n<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">return</SPAN> <SPAN class="token function">declare</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN>SearchComponent<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">{</SPAN> i18n<SPAN class="punctuation token">:</SPAN> i18n<SPAN class="punctuation token">,</SPAN> templateString<SPAN class="punctuation token">:</SPAN> template<SPAN class="punctuation token">,</SPAN> sortField<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"title"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
[install dir]\server\apps\[app#]\widgets\AddData\search\templates\SortOptions.html line 5 and 6:
(remove the selected property from line 5 and add it to line 6)
<SPAN class="operator token"><</SPAN>div <SPAN class="keyword token">class</SPAN><SPAN class="operator token">=</SPAN><SPAN class="string token">"search-sort-options"</SPAN><SPAN class="operator token">></SPAN> <SPAN class="operator token"><</SPAN>label <SPAN class="keyword token">for</SPAN><SPAN class="operator token">=</SPAN><SPAN class="string token">"${id}_select"</SPAN> <SPAN class="keyword token">class</SPAN><SPAN class="operator token">=</SPAN><SPAN class="string token">"sort-prompt"</SPAN><SPAN class="operator token">></SPAN>$<SPAN class="punctuation token">{</SPAN>i18n<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">.</SPAN>sortOptions<SPAN class="punctuation token">.</SPAN>prompt<SPAN class="punctuation token">}</SPAN><SPAN class="operator token"><</SPAN><SPAN class="operator token">/</SPAN>label<SPAN class="operator token">></SPAN> <SPAN class="operator token"><</SPAN>select id<SPAN class="operator token">=</SPAN><SPAN class="string token">"${id}_select"</SPAN> data<SPAN class="operator token">-</SPAN>dojo<SPAN class="operator token">-</SPAN>type<SPAN class="operator token">=</SPAN><SPAN class="string token">"dijit/form/Select"</SPAN> data<SPAN class="operator token">-</SPAN>dojo<SPAN class="operator token">-</SPAN>attach<SPAN class="operator token">-</SPAN>point<SPAN class="operator token">=</SPAN><SPAN class="string token">"sortSelect"</SPAN><SPAN class="operator token">></SPAN> <SPAN class="operator token"><</SPAN>option value<SPAN class="operator token">=</SPAN><SPAN class="string token">""</SPAN><SPAN class="operator token">></SPAN>$<SPAN class="punctuation token">{</SPAN>i18n<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">.</SPAN>sortOptions<SPAN class="punctuation token">.</SPAN>relevance<SPAN class="punctuation token">}</SPAN><SPAN class="operator token"><</SPAN><SPAN class="operator token">/</SPAN>option<SPAN class="operator token">></SPAN> <SPAN class="operator token"><</SPAN>option value<SPAN class="operator token">=</SPAN><SPAN class="string token">"title"</SPAN> selected<SPAN class="operator token">=</SPAN><SPAN class="string token">"selected"</SPAN><SPAN class="operator token">></SPAN>$<SPAN class="punctuation token">{</SPAN>i18n<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">.</SPAN>sortOptions<SPAN class="punctuation token">.</SPAN>title<SPAN class="punctuation token">}</SPAN><SPAN class="operator token"><</SPAN><SPAN class="operator token">/</SPAN>option<SPAN class="operator token">></SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Robert, THANK YOU for the 423rd time!!
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.