agsjs.dijit.TOC now supports FeatureLayer and AMD compatible

4940
28
07-26-2013 10:51 AM
NianweiLiu
Occasional Contributor II
Hello,
  For those folks that use the widget agsjs.dijit.TOC, please be aware that a few enhancements have been put in, specifically:

--FeatureLayer. Supports Simple, UniqueValue and Range Renderer.
--AMD compatible. support both AMD and classic syntax (with sample code).
--fixed some problem when refresh after layer list change.

Some of the fairly complex but less known functionality was dropped to simplify the code upgrade, such as creation of check box on legend items based on UniqueValueRenderer, etc.

For live sample and download, please go to
http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109

Nianwei Liu
Charlotte, NC
28 Replies
AdrianMarsden
Regular Contributor II
Some of the fairly complex but less known functionality was dropped to simplify the code upgrade, such as creation of check box on legend items based on UniqueValueRenderer,


I just noticed this, shame, I was selling that as a neat new feature to my users - any chance of adding this back in as an option?  I agree it wasn't for everyone, as if you had a poorly index/large layer it did have a server hit.

Cheers

ACM
Reply
0 Kudos
AdrianMarsden
Regular Contributor II
Nianwei Liu - this may be a caching/IIS/IE thing but my users are mentioning that sometime the expand button (the little cross) vanishes from collapsed TOCs - I've yet to be able to repeat this, but when it does happen a clear of the IE cache seems to work.

Has anyone else had these issues?

Cheers

ACM
Reply
0 Kudos
KevinMacLeod1
Occasional Contributor III
I just noticed this, shame, I was selling that as a neat new feature to my users - any chance of adding this back in as an option?  I agree it wasn't for everyone, as if you had a poorly index/large layer it did have a server hit.

Cheers

ACM


amarsden which version was this?  This would save me an incredible amount of time and I will downgrade one of my sites to get this, if it works the way I think it does based on your post.  Can I ask what you mean by this?  So, let's say I have a few dozen layers.  They came from CAD and only have on attribute, 'Layer'.  Things like Road, Driveway, Parking, etc for one layer, for example.  Are you saying that, at least previous versions of AGS JS TOC, would allow us to turn of PART of a layer, based on attribute?  So if I have a Paved Areas layer, with Road, Parking, and Driveway attributes, I would see three checkboxes under the 'Paved Areas' layer and I could turn off just parking, with an older AGS JS TOC?  That would be great for us on one viewer.
Reply
0 Kudos
AdrianMarsden
Regular Contributor II
Yep - you had to add a query statement for some reason in the layer, but 1=1 (ie everything) did the trick.

I think build 2.4 did it.

On the other hand if you had grouped lots of attribute, (say cad feature = Building, Garage, Shed) as one style, the TOC would break them out again.
Reply
0 Kudos
NianweiLiu
Occasional Contributor II
So if I have a Paved Areas layer, with Road, Parking, and Driveway attributes, I would see three checkboxes under the 'Paved Areas' layer and I could turn off just parking, with an older AGS JS TOC?


That was the most powerful and complex feature in the widget. It look thorough the uniquevaluerenderer, breaks up values, create check boxes for each, and based on what user checked, generate a definition query (mainly with "OR" in where clause) and pass to server to display a subset.  Unfortunately, there was a bug(NIM074988) in REST API that can not handle passed in definitions correctly if the predefined expression contains an "OR" in where clause without full parenthesis around it. That was the case for the sample map service. It was not fixed for a long time.  Esri eventually declined the bug because not producible in latest version, but they also no longer return the predefined query expression in the layer meta data, that also have impact on the code. On top of that, if the application code actually set query definition manually, it became quite difficult to sync what the TOC trying to do and what the application trying to do. With all these issues, that function was dropped. If you do want that, you can use v2.04 before you upgrade your server to a version that no longer returns predefined expression such as 10.2.

you had to add a query statement for some reason in the layer, but 1=1 (ie everything) did the trick.


A pre-defined definitionExpression (even 1=1) is used in the code as a trigger to generating checkboxs for UniqueValueRenderer's individual value. It was stated in the "build legend node" section of the source code.
Reply
0 Kudos
GokuSan
New Contributor II

Great job. I'm working the last version (update 2015-01-15) but I'm having problems when the layer is a ArcGISDynamicMapServiceLayer and applies a layerDrawingOptions. The problem is that the legend is drawn in the toc does not match the loaded in the map layer; in this case , the legend of toc equals legend MapService. Does anybody have the same problem?

Reply
0 Kudos
MikeCrook
New Contributor III

This may be low priority but I'll ask it anyways. This TOC worked perfectly in ESRI JavaScript 3.xx. I'm now working in ESRI JavaScript 4.0+ beta. It's possible maybe it needs to be implemented a different way but it doesn't seem to work properly in the latest JS API version. Thanks for your hard work on this.

Will you build a new version that will play will with ERSI's JavaScript 4.0 API?

KevinMacLeod4
Frequent Contributor

I hope so, too.  The ESRI layer list lacks integrated legend, transparency, powerful config. A "-" for groups with some but not all sublayers on would also be good to implement.

Reply
0 Kudos
debbiedeng
New Contributor

I need help to automatically uncheck the checkbox next to  Root layer Topographic Contours on agsjs.dijit.toc. Topographic Contours is a cached tile map service that is not like dynamic map service -- easily make layers visible or invisible. Thanks.

Reply
0 Kudos