I am using Flexviewer2.4. I use the EditWidget to show the attribute inspector to users. I need to disable/enable some field inspectors based on the status value of a particular field and use role.I put the enable/disable function in the showFeature event, see the code below. But it does not apply the changes immediately. I used refresh method of AttributeInpsector . It does not work.Any help is appreciated,private function attributeInspector_showFeatureHandler(event:AttributeInspectorEvent):void
{ editor.attributeInspector.activeFeatureLayer.disableClientCaching=true;
if(event.type.toLowerCase() == "showfeature")
{
enableDisable_fieldInpectors();
}
}
and private function enableDisable_fieldInpectors():void
{
var role:String=FlexGlobals.topLevelApplication.role;
var activeFeature:Graphic=editor.attributeInspector.activeFeature;
if (activeFeature.attributes['EDITCOMPLETE']=="YES"){ status="EDITCOMPLETE";}
else {status="NEW";}
if (activeFeature.attributes['QCCOMPLETE']=="YES"){ status="QCEDITCOMPLETE";}
var disableFields:Array;
if (((role=="ArchHistorian"))&&(status=="NEW")){
disableFields=new Array('CREATEDBY','CREATEDON','REDLINEEDITCOMMENT','EDITORNAME','EDITCOMPLETE','EDITCOMPLETEDATE','QCNAME','QCCOMPLETE','QCDATE','REDLINECOMMENTISACTIVE' );
}
else if(role=="GISTech")
{
disableFields=new Array('FEATURETYPE','FEATUREID','NAME','ADDRESS','REDLINENRHPSTATUS','REDLINEEFFECT','REDLINEDIRECTPHYSICALIMPACT','REDLINEHISTORICDISTRICT','REDLINEISCONTRIBUTING','REDLINEFEATUREISACTIVE','REDLINECOMMENT','CREATEDBY','CREATEDON','EDITORNAME','EDITCOMPLETEDATE','QCNAME','QCCOMPLETE','QCDATE','REDLINECOMMENTISACTIVE' );}
else {
disableFields=new Array('FEATURETYPE','FEATUREID','NAME','ADDRESS','REDLINENRHPSTATUS','REDLINEEFFECT','REDLINEDIRECTPHYSICALIMPACT','REDLINEHISTORICDISTRICT','REDLINEISCONTRIBUTING','REDLINEEDITCOMMENT','REDLINEFEATUREISACTIVE','REDLINECOMMENT','CREATEDBY','CREATEDON','EDITORNAME','EDITCOMPLETE','EDITCOMPLETEDATE','QCNAME','QCDATE','REDLINECOMMENTISACTIVE');
}
var fieldInspectors:* = editor.attributeInspector.fieldInspectors;
// Loop items and trigger update event
for (var i:Number = 0; i < fieldInspectors.length; i++)
{
var field:FieldInspector=fieldInspectors;
if (disableFields.indexOf(field.fieldName)>-1) {
field.enabled=false;
}else { field.enabled=true;}
}
editor.attributeInspector.deleteButton.visible=false;
editor.attributeInspector.refresh();
}