targeting attribute inspector of editor

3080
10
01-06-2011 10:11 AM
timgogl
New Contributor II
i need to interact with the attribute inspector as it's various events happen.
i have on my page a defined editor, and template picker, the template picker is associated with the editor in the params used to create the editor. here is the code:

  function addEditor(r){
   
   var contentHolder = "<div id='editorDiv'></div><div id='tmpDiv'></div>";
   $j('##editDiv').append(contentHolder);
   
   var templateLayers = dojo.map(r,function(result){
    return result.layer;
   });
   
   var widget = new esri.dijit.editing.TemplatePicker({
    featureLayers: templateLayers,
    grouping: true,
    rows: 'auto',
    columns: 3
   },'tmpDiv');
   widget.startup();
   
   var layers = dojo.map(r, function(result) {
    return {featureLayer:result.layer};
   });
   
   var settings = {
    map: map,
    templatePicker: widget,//   <------- templatePicker for editor ----->
    geometryService: new esri.tasks.GeometryService(GEOSERVICE),
    layerInfos:layers,
    toolbarVisible: true,
    createOptions: {
     polylineDrawTools:[ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYLINE],
     polygonDrawTools: [ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON,
                         esri.dijit.editing.Editor.CREATE_TOOL_CIRCLE,
                         esri.dijit.editing.Editor.CREATE_TOOL_TRIANGLE,
                         esri.dijit.editing.Editor.CREATE_TOOL_RECTANGLE ]
    },
    toolbarOptions: {
     reshapeVisible: true
    }
   };
   var params = {settings: settings};   
   
   myEditor = new esri.dijit.editing.Editor(params,'editorDiv');
   myEditor.startup();  
   
  }



so, via settings / params, i have associated which templatePicker the editor is using.

is there a way i can do the same thing with the attribute inspector? or do i need to worry about that? can i just create an attribute inspector, and make connections to the eventhandlers for it, and the editor will automatically know whats going on?

heh. i dont know if that even makes sense.


hrm...

just to be more clear. or give a better picture of one of the things i want to do.

when i user drags on object from the template picker and drops it on the map, the attribute inspector opens in an info window. i want to populate the 'creator' field in the attribute inspector with the user information i have captured when the map is loaded.

if an already existing object from the feature layer is selected, and the user changes an attribute in the inspector, i want to populate the 'editor' field and the 'editdate' field

i dont think doing this will be that hard, i am just not sure how to target the attribute editor inside the currently defined editor.

heh. hope that is more clear.
0 Kudos
10 Replies
timgogl
New Contributor II
still no luck.....

so i have been looking at the source for the editor-all

and looking at it, i am making some assumptions (and maybe i am way off....) anway.

this section:
        _createAttributeInspector: function(){
            if (!this._settings.attributeInspector) {
                this._customAttributeInspector = false;
                var map = this._settings.map;
                map.infoWindow.setContent("<div id='content' style='width:100%'></div>");
                map.infoWindow.setTitle(esri.bundle.widgets.attributeInspector.NLS_title);
                map.infoWindow.resize(350, 375);
                this._attributeInspector = new esri.dijit.AttributeInspector({
                    layerInfos: this._settings.layerInfos
                }, dojo.byId("content"));
            }
            else {
                this._customAttributeInspector = true;
                this._attributeInspector = this._settings.attributeInspector;
            }
            .
            .
            .
       }

seems to indicate with the if() block that inside of settings i can define my own attributeInspector.
which i now have done, i am just not sure i have done it correctly.
here is my current block of code (the pertinent part):
   
 var layers = dojo.map(r, function(result) {
  return {featureLayer:result.layer};
 });
 
 var ai = new esri.dijit.AttributeInspector({layerInfos:[layers]}, "attrInspector");
 
 var settings = {
  map: map,
  attributeInspector: ai,
  templatePicker: widget,
  geometryService: new esri.tasks.GeometryService(GEOSERVICE),
  layerInfos:layers,
  toolbarVisible: true,
  createOptions: {
   polylineDrawTools:[ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYLINE],
   polygonDrawTools: [ esri.dijit.editing.Editor.CREATE_TOOL_FREEHAND_POLYGON,
                       esri.dijit.editing.Editor.CREATE_TOOL_CIRCLE,
                       esri.dijit.editing.Editor.CREATE_TOOL_TRIANGLE,
                       esri.dijit.editing.Editor.CREATE_TOOL_RECTANGLE ]
  },
  toolbarOptions: {
   reshapeVisible: true
  }
 };
 var params = {settings: settings};

 myEditor = new esri.dijit.editing.Editor(params,'editorDiv');
 myEditor.startup();
 
       //aiChange is defined ouside this function 
       aiChange = dojo.connect(ai,'onAttributeChange',attributesChanged);



my concern is that i am not defining my layers correctly in the line i instantiate my attribute inspector.

anyone see anything glaring?

thanks for looking.
0 Kudos
timgogl
New Contributor II
hrm... im not even sure if i will be able to overwrite the editor.attributeInspectors built in evenhandlers. whether i can make my own or target the exsisting default one anyway... heh... this may all be a pipedream....
MaritTenfjord
New Contributor
Did you ever figure this out? I am also trying to integrate a custom attribute inspector with the editing widget and finding only limited resources.
ScottLehto2
New Contributor II

Boy I was looking at the same thing. Were you ever able to find anything?

0 Kudos
JohnGrayson
Esri Regular Contributor

The Editor gives you access to the Edit toolbar:

Editor | API Reference | ArcGIS API for JavaScript 3.20 

Just listen for the 'activate' event which give you the current graphic:

Edit | API Reference | ArcGIS API for JavaScript 3.20 

You can update the desired attribute of the graphic, then refresh the AttributeInspector:

AttributeInspector | API Reference | ArcGIS API for JavaScript 3.20 

ScottLehto2
New Contributor II

Perfect. The attribute inspector was the piece of information i was looking for. It was hiding in plain sight. lol.

Question for you John: Do you have any knowledge of extending the attribute inspector? 

I see that it has constants of textbox, text area and richtext and i was looking to introduce filteringselect/combobox functionality to my application. In reality, i just wanted to load in values so users wouldn't have to type in everything. It would also provide some data editing quality control.

Based on what i saw, the functionality i want seems like a stretch, but perhaps i have it wrong. I figured i would ask anyway.

0 Kudos
ScottLehto2
New Contributor II

When i say load in values, i mean loading in a list of value choices, not predefined/absolute values for a feature.

0 Kudos
JohnGrayson
Esri Regular Contributor

From AttributeInspector | API Reference | ArcGIS API for JavaScript 3.20 - "The AttributeInspector widget honors the domains and subtypes as defined by the Feature Service."  This means that a dropdown list of appropriate values will be presented to the user, and this is the best way to add the functionality you need as you're ensuring only one of the correct values are used and these constraints are available throughout the system and not just your app.  Additionally, if you need more control, you can specify your own dijit to handle the update for a specific field by using the 'customField' property when specifying the 'fieldInfos' of a 'layerInfo' in the AttributeInspector constructor. 

TheKenerson
Occasional Contributor

This is fantastic. Thank you. Off to the races.

0 Kudos