[OpenLayers-Users] changing the state of a selected feature

Marco Scheuble mail at marco-scheuble.de
Tue Jan 5 07:10:33 EST 2010


Hi Eric and Jorge,
thank you both, it works fine this way!
cheers Marco

Am 05.01.2010 12:45, schrieb Jorge Gustavo Rocha:
> Hi Marco,
>
> I don't use the toState method, but changing the property directly does
> work.
>
> For example:
> /*
> * allow editing the selected feature
> */
> (...)
> featureToBeModify = someVecLayer.selectedFeatures[0];
> theCorrespondingForm.getForm().items.each(unsetReadOnly);
> (...)
> /*
> * save
> */
> if (featureToBeModify.state != OpenLayers.State.UPDATE) {
> 	featureToBeModify.state = OpenLayers.State.UPDATE
> }
> var rec = theCorrespondingForm.getForm().getValues();
> featureToBeModify.attributes.one = rec.one;
> featureToBeModify.attributes.two = rec.two;
> (...)
> saveStrategy.save();
>
> As you can see, state can/should be changed to allow the feature be
> written in the save operation.
>
> I hope it helps,
>
> Jorge
>
> Ter, 2010-01-05 às 11:57 +0100, Marco Scheuble escreveu:
>    
>> Hi list,
>>
>> after selecting a feature and editing its attributes, I want to save the
>> changes.
>> Unfortunately the state of the selected feature isn't set, so changes
>> would not be saved.
>> Trying to set the state manually with: feature.toState() won't work, too.
>>
>> I'm doing it like this:
>> point.events.on({
>>      "featureselected": function(e) {
>>       showAttributes(e.feature);
>>     },
>>     "featureunselected": function(e) {
>>       hideAttributes(e.feature);
>>     }
>> });
>>
>> function showAttributes(feature){
>>       document.getElementById("label").value = feature.attributes.label;
>> }
>>
>> function hideAttributes(feature){
>>       feature.attributes.label = document.getElementById("label").value;
>>       feature.toState("Update");
>>       alert(feature.state);
>> }
>>
>> alert(feature.state) ->  null
>>
>> anyone can help me?
>> cheers, marco
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>      
>
>    




More information about the Users mailing list