attribute inspector editing

641
0
02-26-2014 04:30 AM
nita14
by
Frequent Contributor
I would like to be able to add new line features, and then fill in the attributes. My workflow is following

1) create draw toolbar
2) activate draw a polyline
3) sketch a new line
4) on double-click, create infowindow
5) fill-in attributes
6) click Save button
7) deactivate draw a polyline


I am using web map from ArcGIS.com (with one feature layer added) and a boiler template from GitHub. I encounet a problem when i want to display attributes in the attInspector

here is my code:

draw : function() {

            var symbol = new SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 2);

            var toolbar = new Draw(this.map, {
                tooltipOffset : 5
            });

            toolbar.activate(esri.toolbars.Draw.POLYLINE);
            var _self = this;

            
             this.fs = new  FeatureLayer("http://services1.arcgis.com/BNOHq9FCYUCPx1D8/ArcGIS/rest/services/trasy_test_gpx/FeatureServer/0",  {
                mode : FeatureLayer.MODE_SELECTION,
                outFields    : ["*"]
            });
            

            this.fs.on("edits-complete", function() {
                this.fs.refresh();
            });

            this.layerInfos = [{
                'featureLayer' : this.fs,
                'showAttachments' : true,
                'isEditable' : true,
                'fieldInfos' : [{
                    'fieldName' : 'Nazwa_trasy',
                    'isEditable' : true,
                    'tooltip' : 'Nazwa trasy',
                    'label' : 'Nazwa trasy:'
                }, {
                    'fieldName' : 'Opis_trasy',
                    'isEditable' : true,
                    'tooltip' : 'Opis trasy',
                    'label' : 'Opis trasy:'
                }, {
                    'fieldName' : 'D??ugo????_trasy__km_',
                    'isEditable' : true,
                    'label' : 'D??ugo???? trasy w kilometrach:'
                }]
            }];

            this.attInspector = new AttributeInspector({
                layerInfos : this.layerInfos
            }, domConstruct.create("div"));
            
            this.attInspector.startup();
         
            //add a save button next to the delete button
            var saveButton = new Button({
                label : "Save",
                "class" : "saveButton"
            });

            domConstruct.place(saveButton.domNode, this.attInspector.deleteBtn.domNode, "after");

           

            toolbar.on("draw-end", function(evt) {
                

                var scr = _self.map.toScreen(evt.geometry.getExtent().getCenter());
                
                var graphic = new Graphic(evt.geometry, symbol);
                _self.map.graphics.add(graphic);
                console.log(_self.attInspector);
        
                _self.map.infoWindow.setTitle("Informacje o trasie");
              
                _self.map.infoWindow.setContent(_self.attInspector.domNode);    
                _self.map.infoWindow.show(scr, _self.map.getInfoWindowAnchor(scr));
              

                
                 
                 _self.attInspector.on("attribute-change", function(evt) {
                    //store the updates to apply when the save button is clicked
                    updateFeature.attributes[evt.fieldName] = evt.fieldValue;
                });
               
                toolbar.deactivate();
            });

        },






Any help is much appreciated.

Thanks
0 Kudos
0 Replies