query.fields

2418
6
07-10-2014 06:18 AM
AlexandrIvanov
New Contributor

Hello.

I'm doing an application based on a sample - ArcGIS API for JavaScript Sandbox

Only in my case initially loaded all the fields:

//build query filter

query = new esri.tasks.Query();

query.outSpatialReference = {"wkid": 102100};

query.returnGeometry = true;

query.outFields = ["*"];

//create the infoTemplate to be used in the infoWindow.

infoTemplate = new esri.InfoTemplate("${FIELD_NAME}", "${*}");

Next I need to be able to choose the displayed fields, how can I get a list of all the fields layer

Thanks in advance and sorry for my english

0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor

You can use this to list all the fields

infoTemplate = new esri.InfoTemplate("Attributes", "${*}");

0 Kudos
AlexandrIvanov
New Contributor

I do so, but how do I get such a third element of this list?

0 Kudos
KenBuja
MVP Esteemed Contributor

I'm not sure what you mean by a third element. Can you explain that in more detail?

0 Kudos
AlexandrIvanov
New Contributor

I load into the application map
load all the attributes:
infoTemplate = new esri.InfoTemplate("Attributes", "${*}");

now I want to get the first, third and fifth attribute from the list what they do not know.
For example: with the line "infoTemplate = new esri.InfoTemplate("Attributes", "${*}");  I get a list of attributes:
number
name
surname
rent
date1
date2
data3
when after press a button I should get a window with the inscription
number, surname, date1


something like -
I load into the application map
load all the attributes:
infoTemplate = new esri.InfoTemplate("Attributes", "${*}");

now I want to get the first, third and fifth attribute from the list what they do not know.
For example: with the line "infoTemplate = new esri.InfoTemplate("Attributes", "${*}");  I get a list of attributes:
number
name
surname
rent
date1
date2
data3
when after press a button I should get a window with the inscription
number, surname, date1


something like:

alert(infoTemplate.content[1] + "; "+ infoTemplate.content[3]+", "+infoTemplate.content[5])

0 Kudos
LuciHawkins
Occasional Contributor III

Are you saying that you will not know the names of the fields until after the first query is run?  Then you want to select the fields from the first query to show in the infowindow?

or

If you want an infotemplate with just your 3 fields - number, surname, date1  - use the following:

var infoTemplate = new InfoTemplate("Attributes", "<tr>number:<td>${number}</tr></td><br><tr>surname:<td>${surname}</tr></td><br><tr>date1:<td>${date1}</tr></td>");


Luci

0 Kudos
AlexandrIvanov
New Contributor

I made the ability to upload any layer. Therefore I am do not know what attributes of the table will be loaded. For further action I need to know the names of these attributes. The first attribute, third and fifth - is for illustrative purposes only

0 Kudos