locked
How to set a new custom datetime field type to display in view the date only? RRS feed

  • Question

  • Hi!. Tell me, please, can I somehow configure the custom field so that the view is not displayed during the time in the form of zeros next to the date?
    To get this same effect as the use of Type = "DateTime" Format = "DateOnly".

    http://i027.radikal.ru/1107/c9/0c2fb78e8421.png

      schema

    <Field ID="{0A212CBC-180B-4870-B75B-CE13199F0761}"
     Name="DateCreated"
     Description=""
     DisplayName="Дата создания"
     StaticName="DateCreated"
     Type="DueDateDefault" />
    

      xml

    <FieldType>
     <Field Name="TypeName">DueDateDefault</Field>
     <Field Name="ParentType">DateTime</Field>
     <Field Name="TypeDisplayName">Срок выполнения поручения (Текущая дата + 2)</Field>
     <Field Name="TypeShortDescription">Срок выполнения поручения (Текущая дата + 2)</Field>
     <Field Name="UserCreatable">TRUE</Field>
     <Field Name="ShowInListCreate">TRUE</Field>
     <Field Name="ShowInSurveyCreate">TRUE</Field>
     <Field Name="ShowInDocumentLibraryCreate">TRUE</Field>
     <Field Name="ShowInColumnTemplateCreate">TRUE</Field>
     <Field Name="FieldTypeClass">MVZ.Fields.DueDateDefaultField, $SharePoint.Project.AssemblyFullName$</Field>
     </FieldType>
    

      .cs

    public class DueDateDefaultField : SPFieldDateTime
    {
     public DueDateDefaultField(SPFieldCollection fields, string fieldName) : base(fields, fieldName)
     {
     DisplayFormat = SPDateTimeFieldFormatType.DateOnly;
     }
     
     public override object DefaultValueTyped
     {
     get
     {
     return DateTime.Now.Date.AddDays(2);
     }
     
     }
    }
    

     



    • Moved by Mike Walsh FIN Wednesday, July 13, 2011 10:10 AM customization (From:SharePoint - Development and Programming (pre-SharePoint 2010))
    Wednesday, July 13, 2011 7:46 AM

Answers

  • Convert that to a string & then try.


    Happy Sharepointing... Regards SPTECH07

    Moderator Note: NEVER propose your own posts as answers. The function is so you can propose the good answers of other people. NOT your own.

    • Proposed as answer by Manu Kaura Friday, July 15, 2011 8:24 PM
    • Unproposed as answer by Mike Walsh FIN Saturday, July 16, 2011 7:00 AM
    • Edited by Mike Walsh FIN Saturday, July 16, 2011 7:01 AM Moderator note added about not proposing own posts
    • Marked as answer by star.warsModerator Sunday, July 24, 2011 12:23 PM
    Friday, July 15, 2011 8:24 PM

All replies

  • Convert that to a string & then try.


    Happy Sharepointing... Regards SPTECH07

    Moderator Note: NEVER propose your own posts as answers. The function is so you can propose the good answers of other people. NOT your own.

    • Proposed as answer by Manu Kaura Friday, July 15, 2011 8:24 PM
    • Unproposed as answer by Mike Walsh FIN Saturday, July 16, 2011 7:00 AM
    • Edited by Mike Walsh FIN Saturday, July 16, 2011 7:01 AM Moderator note added about not proposing own posts
    • Marked as answer by star.warsModerator Sunday, July 24, 2011 12:23 PM
    Friday, July 15, 2011 8:24 PM
  • Sorry Mike.. will keep that in mind...
    Happy Sharepointing... Regards SPTECH07
    Monday, July 18, 2011 2:12 PM