Rendering

3477
8
Jump to solution
07-20-2015 02:41 AM
SatyanarayanaNarmala
New Contributor III

Hi

 

i am using this example exactly to show renedering based on values.

 

https://developers.arcgis.com/javascript/jssamples/renderer_generate_renderer.html

 

app.fields = {

          "sde.sde.CONST_WISE_HOUSING.total_bens": "Total Beneficiaries", "sde.sde.CONST_WISE_HOUSING.sc": "SC Beneficiaries", "sde.sde.CONST_WISE_HOUSING.st": "ST Beneficiaries",

          "sde.sde.CONST_WISE_HOUSING.bc": "BC Beneficiaries", "sde.sde.CONST_WISE_HOUSING.others": "Others Beneficiaries" , "sde.sde.CONST_WISE_HOUSING.bbl": "Below Basement Level Stage", "sde.sde.CONST_WISE_HOUSING.bl": "Basement Level Stage",

          "sde.sde.CONST_WISE_HOUSING.ll": "Lentel Level Stage", "sde.sde.CONST_WISE_HOUSING.rl": "Roof Level Stage", "sde.sde.CONST_WISE_HOUSING.completion":"Completed Stage"

        };

 

 

 

app.outFields = ["sde.sde.CONST_WISE_HOUSING.total_bens", "sde.sde.CONST_WISE_HOUSING.sc", "sde.sde.CONST_WISE_HOUSING.st", "sde.sde.CONST_WISE_HOUSING.bc", "sde.sde.CONST_WISE_HOUSING.others", "sde.sde.CONST_WISE_HOUSING.bbl", "sde.sde.CONST_WISE_HOUSING.bl", "sde.sde.CONST_WISE_HOUSING.ll", "sde.sde.CONST_WISE_HOUSING.rl", "sde.sde.CONST_WISE_HOUSING.completion", "sde.sde.AP_Const.asmbname"];

 

 

When i add "sde.sde.AP_Const.asmbname"  to out fields, drop down not working, showing an error with filtering Select

 

where am i going wrong

 

 

these are the fields

 

 

 

    sde.sde.AP_Const.objectid ( type: esriFieldTypeOID , alias: objectid )

    sde.sde.AP_Const.dname ( type: esriFieldTypeString , alias: dname , length: 30 )

    sde.sde.AP_Const.asmbname ( type: esriFieldTypeString , alias: asmbname , length: 30 )

    sde.sde.AP_Const.cons_id ( type: esriFieldTypeSmallInteger , alias: cons_id )

    sde.sde.AP_Const.shape ( type: esriFieldTypeGeometry , alias: shape )

    sde.sde.AP_Const.st_area(shape) ( type: esriFieldTypeDouble , alias: st_area(shape) )

    sde.sde.AP_Const.st_length(shape) ( type: esriFieldTypeDouble , alias: st_length(shape) )

    sde.sde.CONST_WISE_HOUSING.objectid ( type: esriFieldTypeInteger , alias: objectid )

    sde.sde.CONST_WISE_HOUSING.constcode ( type: esriFieldTypeInteger , alias: constcode )

    sde.sde.CONST_WISE_HOUSING.total_bens ( type: esriFieldTypeInteger , alias: Total_bens )

    sde.sde.CONST_WISE_HOUSING.sc ( type: esriFieldTypeInteger , alias: SC )

    sde.sde.CONST_WISE_HOUSING.st ( type: esriFieldTypeInteger , alias: ST )

    sde.sde.CONST_WISE_HOUSING.bc ( type: esriFieldTypeInteger , alias: BC )

    sde.sde.CONST_WISE_HOUSING.others ( type: esriFieldTypeInteger , alias: others )

    sde.sde.CONST_WISE_HOUSING.bbl ( type: esriFieldTypeInteger , alias: BBL )

    sde.sde.CONST_WISE_HOUSING.bl ( type: esriFieldTypeInteger , alias: BL )

    sde.sde.CONST_WISE_HOUSING.ll ( type: esriFieldTypeInteger , alias: LL )

    sde.sde.CONST_WISE_HOUSING.rl ( type: esriFieldTypeInteger , alias: RL )

    sde.sde.CONST_WISE_HOUSING.completion ( type: esriFieldTypeInteger , alias: Completion )

    sde.sde.AP_Const.state ( type: esriFieldTypeString , alias: sde.sde.AP_Const.state , length: 20 )

0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Occasional Contributor III

Satya,

Sorry, I was just trying to explain why your FilteringSelect was not working. I shall try to explain a bit more.

Even though the app.outFields contains the STATE_NAME and NAME it is not adding them to the dropdown item source by excluding them since they are not part of the app.Fields. probably instead of telling you to add it to app.Fields I should have said to exculde your name field from while populating items source. see the below line of code

          if ( arrayUtils.indexOf(f.split("_"), "NAME") == -1 ) { // exclude attrs that contain "NAME"
            fieldNames.items.push({ "name": app.fields[f], "value": f });
          }

It is excluding/skipping for STATE_NAME & NAME, to be more precise, if any field name, contains word NAME after splitting with '_' as delimiter. So the name fields will not be part of dropdown list. For identify apart from template, you also need to look at below line of code where the title is being set for info window.


            var name = evt.graphic.attributes.NAME + " County",
                 ca = app.currentAttribute,
                 content = app.fields[ca] + ": " + number.format(evt.graphic.attributes[ca]);
            app.map.infoWindow.setTitle(name);

Hope this carifies all your doubts.

View solution in original post

8 Replies
thejuskambi
Occasional Contributor III

The app.fields does not contain sde.sde.AP_Const.asmbname. The dropdown is populated is being populated by below code and it used app.outFields to iterate through the app.fields collection.

var fieldNames, fieldStore, fieldSelect;
        fieldNames
= { "identifier": "value", "label": "name", "items": []};
        arrayUtils
.forEach(app.outFields, function(f) {
         
if ( arrayUtils.indexOf(f.split("_"), "NAME") == -1 ) { // exclude attrs that contain "NAME"
            fieldNames
.items.push({ "name": app.fields[f], "value": f });
         
}
       
});

0 Kudos
SatyanarayanaNarmala
New Contributor III

Hi,

When i add "sde.sde.AP_Const.asmbname"  to out fields, drop down not working, It only showing the initialized field based rendering but showing an error with filtering Select in the console.

the dropdown list is almost disabled.

where am i going wrong.

Thanks,

satya

0 Kudos
thejuskambi
Occasional Contributor III

you need to add both field name and label with collen delimited like

"sde.sde.CONST_WISE_HOUSING.sc": "SC Beneficiaries"

but, then the dropdown will show this value also, If you dont want it to show in need to ensure you dont add it to the fieldNames.items.

0 Kudos
SatyanarayanaNarmala
New Contributor III

Hi,

When i add "sde.sde.AP_Const.asmbname"  to out fields, drop down not working, It only showing the initialized field based rendering but showing an error with filtering Select in the console.

its working quite well here

Generate renderer | ArcGIS API for JavaScript

app.outFields = ["POP2007", "POP07_SQMI", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "HAWN_PI", "OTHER", "MULT_RACE", "HISPANIC", "STATE_NAME", "NAME"];

My version

app.outFields = ["sde.sde.CONST_WISE_HOUSING.total_bens", "sde.sde.CONST_WISE_HOUSING.sc", "sde.sde.CONST_WISE_HOUSING.st", "sde.sde.CONST_WISE_HOUSING.bc", "sde.sde.CONST_WISE_HOUSING.others", "sde.sde.CONST_WISE_HOUSING.bbl", "sde.sde.CONST_WISE_HOUSING.bl", "sde.sde.CONST_WISE_HOUSING.ll", "sde.sde.CONST_WISE_HOUSING.rl", "sde.sde.CONST_WISE_HOUSING.completion", "sde.sde.AP_Const.asmbname"];

when i add this sde.sde.AP_Const.asmbname

the dropdown list is almost disabled.

when i remove the sde.sde.AP_Const.asmbname from outfields  everything works fine but the identity does not reflect the sde.sde.AP_Const.asmbname name.

Thanks,

satya

0 Kudos
thejuskambi
Occasional Contributor III

Hello Satya,

I have been explaining the same thing as mentioned earlier. Adding only the new fields in app.outFields will cause problems as they are using that variable to populated the dropdown. That means you would also need to add a corresponding value to app.Fields collection as well. Please note that the app.Fields is a name value object like below.

app.fields = {
     "sde.sde.CONST_WISE_HOUSING.total_bens": "Total Beneficiaries",
     "sde.sde.CONST_WISE_HOUSING.sc": "SC Beneficiaries", 
     "sde.sde.CONST_WISE_HOUSING.st": "ST Beneficiaries",
     "sde.sde.CONST_WISE_HOUSING.bc": "BC Beneficiaries",
     "sde.sde.CONST_WISE_HOUSING.others": "Others Beneficiaries" , 
     "sde.sde.CONST_WISE_HOUSING.bbl": "Below Basement Level Stage",
     "sde.sde.CONST_WISE_HOUSING.bl": "Basement Level Stage",
     "sde.sde.CONST_WISE_HOUSING.ll": "Lentel Level Stage", 
     "sde.sde.CONST_WISE_HOUSING.rl": "Roof Level Stage", 
     "sde.sde.CONST_WISE_HOUSING.completion":"Completed Stage"
};

so along with adding "sde.sde.AP_Const.asmbname" to app.outFields. you need to add "sde.sde.AP_Const.asmbname" : "asmbname".

As far as Identify is concerned only the app is set up to show only the selected attribute value as per the below mentioned code.

                ca = app.currentAttribute,
                content = app.fields[ca] + ": " + number.format(evt.graphic.attributes[ca]);
            app.map.infoWindow.setTitle(name);
            app.map.infoWindow.setContent(content);

Hope this was helpful and if you are still not able to fix it then please send the complete code and I shall take a look at it.

0 Kudos
SatyanarayanaNarmala
New Contributor III

Hi thejus kambi,

I did get you. But my question is as in the example

app.fields does not conatin  "STATE_NAME", "NAME"

but app.outFields does have "STATE_NAME", "NAME"

which is used in   

layer def  

         app.layerDef = "STATE_NAME = 'Washington'";

as well as  pop up definition   

          app.popupTemplate = new PopupTemplate({
          title
: "{NAME} County",

which when i use

app.outFields = ["sde.sde.CONST_WISE_HOUSING.total_bens", "sde.sde.CONST_WISE_HOUSING.sc", "sde.sde.CONST_WISE_HOUSING.st", "sde.sde.CONST_WISE_HOUSING.bc", "sde.sde.CONST_WISE_HOUSING.others", "sde.sde.CONST_WISE_HOUSING.bbl", "sde.sde.CONST_WISE_HOUSING.bl", "sde.sde.CONST_WISE_HOUSING.ll", "sde.sde.CONST_WISE_HOUSING.rl", "sde.sde.CONST_WISE_HOUSING.completion", "sde.sde.AP_Const.asmbname"];

is not working why so ?

Generate renderer | ArcGIS API for JavaScript

app.fields = {
         
"POP2007": "Population(2007)", "POP07_SQMI": "Population/Square Mile(2007)",
         
"WHITE": "White", "BLACK": "Black", "AMERI_ES": "Native Americans",
         
"HISPANIC": "Hispanic", "ASIAN": "Asian", "HAWN_PI": "Native Hawaiian/Pacific Islander",
         
"MULT_RACE": "Multiple Races", "OTHER": "Other"
       
};
       
        app
.map = new Map("map", {
          center
: [-123.113, 47.035],
          zoom
: 7,
          slider
: false
       
});
       
var basemap = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer");
        app
.map.addLayer(basemap);
       
var ref = new ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/Reference/World_Reference_Overlay/MapServer");
        app
.map.addLayer(ref);

       
// various info for the feature layer
        app
.countiesUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/2";
        app
.layerDef = "STATE_NAME = 'Washington'";
        app
.outFields = ["POP2007", "POP07_SQMI", "WHITE", "BLACK", "AMERI_ES", "ASIAN", "HAWN_PI", "OTHER", "MULT_RACE", "HISPANIC", "STATE_NAME", "NAME"];
        app
.currentAttribute = "POP2007";
        app
.popupTemplate = new PopupTemplate({
          title
: "{NAME} County",
          fieldInfos
: [{
           
"fieldName": app.currentAttribute,
           
"label": app.fields[app.currentAttribute],
           
"visible": true,
           
"format": { places: 0, digitSeparator: true }
         
}],
          showAttachments
:true
       
});

Thanks

Satya.

0 Kudos
thejuskambi
Occasional Contributor III

Satya,

Sorry, I was just trying to explain why your FilteringSelect was not working. I shall try to explain a bit more.

Even though the app.outFields contains the STATE_NAME and NAME it is not adding them to the dropdown item source by excluding them since they are not part of the app.Fields. probably instead of telling you to add it to app.Fields I should have said to exculde your name field from while populating items source. see the below line of code

          if ( arrayUtils.indexOf(f.split("_"), "NAME") == -1 ) { // exclude attrs that contain "NAME"
            fieldNames.items.push({ "name": app.fields[f], "value": f });
          }

It is excluding/skipping for STATE_NAME & NAME, to be more precise, if any field name, contains word NAME after splitting with '_' as delimiter. So the name fields will not be part of dropdown list. For identify apart from template, you also need to look at below line of code where the title is being set for info window.


            var name = evt.graphic.attributes.NAME + " County",
                 ca = app.currentAttribute,
                 content = app.fields[ca] + ": " + number.format(evt.graphic.attributes[ca]);
            app.map.infoWindow.setTitle(name);

Hope this carifies all your doubts.

SatyanarayanaNarmala
New Contributor III

Hi thejus kambi,

Got it now.

Thanks ,

Satya

0 Kudos