Hi all,
I was wondering if there is a way to keep ObjectID from displaying when users view the query results in the attribute table.
Any pointers will be greatly appreciated!
Lesi
Lesi,
In the Query Widget Widget.js make this change to the _showResultLayerInfo (line 17 - 21):
_showResultLayerInfo<SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>resultLayerInfo<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">_hideAllSingleQueryResultDijits</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> singleQueryResult <SPAN class="operator token">=</SPAN> resultLayerInfo<SPAN class="punctuation token">.</SPAN>singleQueryResult<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> resutlLayer <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>singleQueryResult<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> html<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setStyle</SPAN><SPAN class="punctuation token">(</SPAN>singleQueryResult<SPAN class="punctuation token">.</SPAN>domNode<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'display'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'block'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">var</SPAN> currentAttrs <SPAN class="operator token">=</SPAN> singleQueryResult<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getCurrentAttrs</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> resutlLayer <SPAN class="operator token">=</SPAN> lang<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getObject</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"query.resultLayer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">false</SPAN><SPAN class="punctuation token">,</SPAN> currentAttrs<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>resutlLayer<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>_activeLayerId <SPAN class="operator token">=</SPAN> resutlLayer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">_hideAllLayers</SPAN><SPAN class="punctuation token">(</SPAN>resutlLayer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> resutlLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">show</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//now show in at widget</SPAN> <SPAN class="keyword token">var</SPAN> layerInfo <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>layerInfosObj<SPAN class="punctuation token">.</SPAN><SPAN class="token function">getLayerInfoById</SPAN><SPAN class="punctuation token">(</SPAN>resutlLayer<SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> array<SPAN class="punctuation token">.</SPAN><SPAN class="token function">map</SPAN><SPAN class="punctuation token">(</SPAN>layerInfo<SPAN class="punctuation token">.</SPAN>layerObject<SPAN class="punctuation token">.</SPAN>fields<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>fld<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">if</SPAN><SPAN class="punctuation token">(</SPAN>fld<SPAN class="punctuation token">.</SPAN>name <SPAN class="operator token">===</SPAN> layerInfo<SPAN class="punctuation token">.</SPAN>layerObject<SPAN class="punctuation token">.</SPAN>objectIdField<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> fld<SPAN class="punctuation token">.</SPAN>show <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">false</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="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">publishData</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="string token">'target'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'AttributeTable'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'layer'</SPAN><SPAN class="punctuation token">:</SPAN> layerInfo <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">{</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>_activeLayerId <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">_hideAllLayers</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="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>
Hello @RobertScheitlin__GISP ! How are you?
I have an application that was developed with web appbuilder 2.2, and I need the objectid fields not to appear in the layer tabs inside the attribute table widget. I checked your code given as a solution, however in the application I need to work on, the "Query" widget does not exist in the list of widgets used in the application. I've tried to debug and change the code inside the attribute table widget.js, but unfortunately I was not successful. Do you have any other suggestions for me?
Thanks in advance for your help.
Gilberto.
Thank you, Robert!
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.