Try our conversational search powered by Generative AI!

Make Modify editable (ichangetrackable_changed)

Vote:
 

Hi,

am trying to make the property Modified editable in Editmode.

Is there a custom written EPiServer Dojo that makes that property read only.
Can i override that?

Are there any other options on the metadata object that i can change?

I have tried like this.

[EditorDescriptorRegistration(TargetType = typeof(DateTime?))]
public class MakeModifiedEditableEditorDescriptor : EditorDescriptor
{
public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable attributes)
{
base.ModifyMetadata(metadata, attributes);

if (metadata.PropertyName.Equals("ichangetrackable_changed"))
{
metadata.ShowForEdit = true;
metadata.ShowForDisplay = true;

metadata.ClientEditingClass = "epi/shell/widget/DateTimeSelectorDropDown";
}

}
}

#154852
Aug 31, 2016 13:52
Vote:
 

Hi!

It won't be enough to just make it editable because you will also have to handle the default backend implementation of the Modified property. Even if you make it editable and change the value manually, Episerver will step in and check if the "Update modified date" is checked. If true, it will set the Modified property to DateTime.Now and overwrite the value set in the UI.

However, this code will make the property editable and you can dig around and see if you can do some workaround to the default backend stuff. :)

[EditorDescriptorRegistration(TargetType = typeof (DateTime?), EditorDescriptorBehavior = EditorDescriptorBehavior.OverrideDefault)]
public class CustomDateTimeEditorDescriptor : EPiServer.Shell.ObjectEditing.EditorDescriptors.DateTimeEditorDescriptor
{
    public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
    {
        base.ModifyMetadata(metadata, attributes);

        if (metadata.PropertyName.Equals("ichangetrackable_changed"))
        {
            metadata.ShowForEdit = true;
            metadata.ShowForDisplay = true;
            metadata.IsReadOnly = false;
        }
    }
}
#154865
Aug 31, 2016 16:11
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.