Select to view content in your preferred language

Customize "Attribute editing - mobile" sample

3031
6
Jump to solution
09-04-2015 07:47 AM
MarcoRosa
Emerging Contributor

Hi to all,

i'm going to customize sample  Attribute editing - mobile | ArcGIS API for JavaScript.

What i would like to do is edit attributes of existing features of map. This is at the moment forbidden: now is possible only insert a new feture modifying attributes.

I've tried modifyng this method in this way:

            on(appGlobals.citizenRequestLayer, "click", function (event){

               //rem this
              //appGlobals
.map.infoWindow.setFeatures([event.graphic]);

               //added

                var currentFeature;

                var query = new Query();

                query.objectIds = [event.graphic.attributes.ID];

                appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) {

                    if (featureSet.features.length > 0) {

                        currentFeature = featureSet.features[0];

                    }

                });

                attributeInspector._currentFeature = currentFeature;

               $.mobile.changePage("#ui-attributes-page", null, true, true);
           
});

when i click on exiting point , i view the message "no features selected".

Can anyone help me ?

Thanks

GP

0 Kudos
1 Solution

Accepted Solutions
thejuskambi
Frequent Contributor

Ok, I finally got it working. The attributeInspector works on the selected features with in the FeatureLayer. so if you change the implementation like below the selected graphic will show up for editing.

var query = new Query();

    query.objectIds = [event.graphic.attributes.objectid];

    appGlobals.citizenRequestLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW).then(function(){

   $.mobile.changePage("#ui-attributes-page", null, true, true);

    });

View solution in original post

6 Replies
thejuskambi
Frequent Contributor

the FeatureLayer queryFeatures is a Deffered method so the set on attributeInspector will be executed before the query is complete you need to change it like below.

          appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) {
                    if (featureSet.features.length > 0) {
                        currentFeature = featureSet.features[0];
                    }
                }).then(function(){
                    attributeInspector._currentFeature = currentFeature;
              });
0 Kudos
MarcoRosa
Emerging Contributor

i thejus,

thanks for the suggestion , i've changed code but the result is the same , it doesn't work.

Hi have same message ... no feature selected 😞

here is the code

                var currentFeature;

                var query = new Query();

                query.objectIds = [event.graphic.attributes.ID];

                appGlobals.citizenRequestLayer.queryFeatures(query, function (featureSet) {

                    if (featureSet.features.length > 0) {

                        currentFeature = featureSet.features[0];

                    }

                }).then(function () {

                    attributeInspector._currentFeature = currentFeature;

                });

                $.mobile.changePage("#ui-attributes-page", null, true, true);

many thanks ciao Giorgio

0 Kudos
thejuskambi
Frequent Contributor

The objectid field for the used citizenRequestLayer is objectid as per Layer: Requests (ID: 0)

you should use

query.objectIds = [event.graphic.attributes.objectid];

0 Kudos
MarcoRosa
Emerging Contributor

Im sorry but nothing ..... doesnt work same result

0 Kudos
thejuskambi
Frequent Contributor

Ok, I finally got it working. The attributeInspector works on the selected features with in the FeatureLayer. so if you change the implementation like below the selected graphic will show up for editing.

var query = new Query();

    query.objectIds = [event.graphic.attributes.objectid];

    appGlobals.citizenRequestLayer.selectFeatures(query, FeatureLayer.SELECTION_NEW).then(function(){

   $.mobile.changePage("#ui-attributes-page", null, true, true);

    });

MarcoRosa
Emerging Contributor

hi thejus,

thanks a lot , it works 🙂

0 Kudos