I'd like to get the count of features, without making another call the the server, after the definition expression of a feature layer is changed. I'm using JSAPI 4.2
After reading through the docs more finally came up with a solution:
I'm using the angular-esri libraries, but the idea is the same. Call that after the definitionExpression is set. I don't think you can even get a count from the featurelayer, had to get it from the featurelayerview. I just had to save that extra call to the server.. Thanks!
Daniel,
There is not. But a work around is to attach a listen for the update-end right before you use setDefinitionExpression and then remove the update-end event listener inside the handler function.
<SPAN class="keyword token">var</SPAN> updateEndHandlerEvt <SPAN class="operator token">=</SPAN> featureLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">on</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'update-end'</SPAN><SPAN class="punctuation token">,</SPAN> updateEndHandler<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> featureLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">setDefinitionExpression</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"blah blah"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="keyword token">function</SPAN> <SPAN class="token function">updateEndHandler</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> updateEndHandlerEvt<SPAN class="punctuation token">.</SPAN><SPAN class="token function">remove</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="comment token">//now do something since the definition expression is applied</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>
Sorry, I should have been more clear in my main post. I'm on 4.2, I only put the version in the hashtag section. I'll update the main question.
I don't see that even in 4.2, I do see a "layerview-create" on the FeatureLayer, but I already tried that and it didn't hit it.
Any other ideas? Thanks!
DJ
I have this exact issue, but it doesn't seem that the event handler for "on-set-definition-expression-complete" has been added. Any other ideas for a simple implementation? It seems the definition expression will break out the query into batches. I need to know when they are all done resolving.
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.