How do I display a text field as a text area?

1108
6
05-24-2011 04:49 PM
indyhurt
New Contributor II
Hi Everyone!  Any help with this would be greatly appreciated.

I've been working on a project to create a few websites that utilize the editing functionality with ArcGIS Server.  I customized the following sample in order to serve up our data:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_multipleAttrInspector.html
If you go to http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm, you will find this sample under Editing - Modify Editable Fields

This is perfect except for one thing I'd like to change.  I have one field that is called "comment" and I'd like that field to show up as a text area.  Something similar to this example:
http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_editing_widget.html
Again, to find this sample, go to http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples_start.htm, and go to Editing - Editor with Toolbar (Union).

I've tried a few times to grab some of the code from the Editing - Editor with Toolbar (Union) sample to add to my sample, but so far I haven't been able to find anything that works.  I thought it would be as simple as grabbing the following code and adding it to my sample but perhaps I'm adding it in the wrong place:

//build the layer and field information for the layer, display the description field
        //using a text area.
        var layers = dojo.map(results, function(result) {
          var fieldInfos= dojo.map(result.layer.fields,function(field){
            if(field.name === 'description'){
              return {'fieldName': field.name,'label':'Details',stringFieldOption:esri.dijit.AttributeInspector.STRING_FIELD_OPTION_TEXTAREA}
            }
            else{
              return {'fieldName': field.name,'lable':field.alias}
            }
          });
          return {featureLayer:result.layer,'fieldInfos':fieldInfos}
        });
0 Kudos
6 Replies
derekswingley1
Frequent Contributor
0 Kudos
indyhurt
New Contributor II
Hi Derek,
I did see that example, but where would I put one of those lines of code if using the sample I mentioned?  I tried adding it in a few places, customizing it to reflect the correct field name, but nothing worked for me.

(http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_multipleAttrInspector.html)
0 Kudos
HemingZhu
Occasional Contributor III
Hi Derek,
I did see that example, but where would I put one of those lines of code if using the sample I mentioned?  I tried adding it in a few places, customizing it to reflect the correct field name, but nothing worked for me.

(http://help.arcgis.com/en/webapi/javascript/arcgis/demos/ed/ed_multipleAttrInspector.html)


var fieldInfos= dojo.map(layer.fields,function(field){
            if (field.name === 'description') {
              return {'fieldName': field.name,'label':'Details',stringFieldOption:esri.dijit.AttributeInspector.STRING_FIELD_OPTION_RICHTEXT}
            }
            else{
              return {'fieldName': field.name,'lable':field.alias}
            }
          });
      
            var layerInfos = [{
              'featureLayer': layer,
              'isEditable': true,
            'fieldInfos':fieldInfos
            }]

            var attInspector = new esri.dijit.AttributeInspector({
              layerInfos: layerInfos
            }, dojo.create("div"));
0 Kudos
derekswingley1
Frequent Contributor
0 Kudos
indyhurt
New Contributor II
Heming Zhu, thank you so much!  That worked with just a little change to make 'isEditable' false instead of true.  Luckily I was able to figure out exactly where those lines of code needed to go.

A text area now displays for existing points when you click on them which is great.  A text area does not display when a user is creating a new point.  While it would be great to have a text area there too, I'm just so thrill to have everything working that I may just leave well enough along.

Derek Swingley, thank you as well!  Your method on stack exchange worked as well - exactly as Heming's method did, only I didn't have to change 'isEditable' to false... it was already done for me.  As I mentioned earlier, I'll leave well enough alone and not worry about how the info window appears when creating a new point.  If it's an easy fix, please let me know.
HemingZhu
Occasional Contributor III
Heming Zhu, thank you so much!  That worked with just a little change to make 'isEditable' false instead of true.  Luckily I was able to figure out exactly where those lines of code needed to go.

A text area now displays for existing points when you click on them which is great.  A text area does not display when a user is creating a new point.  While it would be great to have a text area there too, I'm just so thrill to have everything working that I may just leave well enough along.

Derek Swingley, thank you as well!  Your method on stack exchange worked as well - exactly as Heming's method did, only I didn't have to change 'isEditable' to false... it was already done for me.  As I mentioned earlier, I'll leave well enough alone and not worry about how the info window appears when creating a new point.  If it's an easy fix, please let me know.


The code i provided came from part of my code. I should change a little bit to fit your need (isEditable: false). Sorry for the confustion i caused.  I attached a file which is a modified ESRI sample you mentioned. Pay attention to the highlighted portion. It should allow you to add a feature with text area field.
0 Kudos