Hello Friends, i saw lots of discussions on coded Domain values when doing Query tasks. But not a single is useful for me yet. I am having same question as you explain here. Can you please help me with the same for 4.9 API.
I am having 2 attributes with coded values..I want to add a drop down menu to selecting values for that specific attribute. So user can select specific value of that attribute and perform query task.
Right now am using below function..
Thank you.
let Status = new Query({
returnGeometry: false,
where: '1=1',
returnDistinctValues: true,
outFields: ['STATUS']
});
qTask1.execute(Status).then(function(results) {
results.features.map(function(feat) {
let opt5 = document.createElement('option');
opt5.value = feat.attributes.STATUS;
opt5.innerHTML = feat.attributes.STATUS;
stadd.appendChild(opt5);
});
view.graphic.add(selectedGraphics);
});
let qSubtype = new Query({
returnGeometry: false,
where: '1=1',
returnDistinctValues: true,
outFields: ['SUBTYPE']
});
qTask72.execute(qSubtype).then(function(results) {
results.features.map(function(feat) {
let opt3 = document.createElement('option');
opt3.value = feat.attributes.SUBTYPE;
opt3.innerHTML = feat.attributes.SUBTYPE;
subdd.appendChild(opt3);
});
view.graphic.add(selectedGraphics);
});
Solved! Go to Solution.
Just keep posting to GeoNet that way my answers help more than just you.
Thats absolutely fine Sir.. as you say so.. i'll post it here on GeoNet, as i always do...
Thank You.
Hi Robert, I tried to use your sample but cant able to retrieve domain values. Can you please take a look and tell me what changes i have to made in it..
let qSub = new Query({
returnGeometry: false,
where: '1=1',
returnDistinctValues: true,
outFields: ['SUBTYPE'],
orderByFields: ['SUBTYPE ASC']
});
qTask7.execute(qSub).then(function(results) {
results.features.map(function(feat) {
let opt3 = document.createElement('option');
opt3.value = feat.attributes.SUBTYPE;
opt3.innerHTML = feat.attributes.SUBTYPE;
subdd.appendChild(opt3);
});
view.graphic.add(selectedGraphics);
});
I thought to create new thread but the topic is same so i didn't create new thread..
RAJ,
I don't see anywhere in your code where you are using the example code I provided...
Line 5 is the most important part.
pFL.queryFeatures(qUVp).then(function(results){
arrayUtils.map(results.features, function(feat){
let opt2 = document.createElement('option');
opt2.value = feat.attributes.sex;
opt2.innerHTML = pFL.getFeatureType(feat).name;
sexdd.appendChild(opt2);
});
});
I am trying to get domain value of this Field(SUBTYPE) in the query task menu...
let qSub = new Query({
returnGeometry: false,
where: '1=1',
returnDistinctValues: true,
outFields: ['SUBTYPE'],
orderByFields: ['SUBTYPE ASC']
});
qTask7.execute(qSub).then(function(results) {
arrayUtils.map(results.features, function(feat) {
let opt3 = document.createElement('option');
opt3.value = feat.attributes.SUBTYPE;
const domain = qTask7.getFieldDomain("SUBTYPE", {feature: feat});
opt3.innerHTML = domain.getName(feat.attributes.SUBTYPE);
subdd.appendChild(opt3);
});
});
RAJ,
You can not call getFieldDomain method on a QueryTask, there is no such method. The getFieldDomain method is part of FeatureLayer class.
ok robert.. So i made changes..
let qSub = new Query({
returnGeometry: false,
where: '1=1',
returnDistinctValues: true,
outFields: ['SUBTYPE'],
orderByFields: ['SUBTYPE ASC']
});
San7Lyr.queryFeatures(qSub).then(function(results) {
arrayUtils.map(results.features, function(feat) {
let opt3 = document.createElement('option');
opt3.value = feat.attributes.SUBTYPE;
const domain = San7Lyr.getFieldDomain("SUBTYPE", {feature: feat});
opt3.innerHTML = domain.getName(feat.attributes.SUBTYPE);
subdd.appendChild(opt3);
});
});
And it still does not work?
Still not working..