I am trying to auto populate the custom fields in the editor but no luck.
here is what I thought would work by assigning the value to the textBox but nothing...
var someValue = "My value"; var myTextBox = new dijit.form.TextBox({ id: "firstname", value: someValue }); var txtEmail = new dijit.form.TextBox({ id: "email", value: "my email here" }); var layerInfos = [{ 'featureLayer':featureLayer, 'showAttachments':false, 'showDeleteButton':true, 'fieldInfos':[ {'fieldName':'name','label':'Name','customField': myTextBox}, {'fieldName':'email','label':'Email','customField': txtEmail} ] }];
Solved! Go to Solution.
If you want to set default values for new features you can do this using the feature layer's before-apply-edits event. If you set the default values there they will appear when the popup attribute window displays for new features. Here's an example:
requestLayer.on("before-apply-edits", function(g){
var features = g.adds;
for(i = 0; i < features.length; i++){
var f = features;
f.attributes.name = "Jane Doe";
}
});
Richard,
Have you tried to set the value after you create the textbox?
myTextBox.set('value', 'somevalue');
Hi Robert,
yes I did try that still no luck. the image bellow shows the fields that need to be auto filled.
If you want to set default values for new features you can do this using the feature layer's before-apply-edits event. If you set the default values there they will appear when the popup attribute window displays for new features. Here's an example:
requestLayer.on("before-apply-edits", function(g){
var features = g.adds;
for(i = 0; i < features.length; i++){
var f = features;
f.attributes.name = "Jane Doe";
}
});
Thank you Kelly,
you saved my day !
I've been successful in modifying this code to update fields based on edited fields - however, when you change the driving field after the initial input, it does not update the dependent fields. I believe this has something to do with the "before-apply-edits" but haven't been able to get anything else to work. Kelly, do you have anything that would allow autopopulation that dynamically?
Thanks!