Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Custom field type with decimal places

$
0
0

I have created custom field type with Number ParentType. The problem is with decimal numbers: the comma sign is ignored. I checked in database and sharepoint uses float column but stored number is without decimals. For example for typed value 12.34 stores 1234. Why is that?

I tried debug my code and method GetValidatedString returns "12,34".

Here is field definition

<?xml version="1.0" encoding="utf-8"?><FieldTypes><FieldType><Field Name="TypeName">TimeSpan</Field><Field Name="ParentType">Number</Field><Field Name="TypeDisplayName">$Resources:KRD.Sharepoint.Common,SPFieldTimeSpan_DisplayName;</Field><Field Name="TypeShortDescription">$Resources:KRD.Sharepoint.Common,SPFieldTimeSpan_Description;</Field><Field Name="UserCreatable">TRUE</Field><Field Name="ShowInColumnTemplateCreate">TRUE</Field><Field Name="FieldTypeClass">KRD.Sharepoint.Common.Fields.SPFieldTimeSpan, $SharePoint.Project.AssemblyFullName$</Field></FieldType></FieldTypes>

and field code:

public class SPFieldTimeSpan: SPFieldNumber
  {
    public SPFieldTimeSpan(SPFieldCollection fields, string fieldName) : base(fields, fieldName)
    {
    }

    public SPFieldTimeSpan(SPFieldCollection fields, string typeName, string displayName) : base(fields, typeName, displayName)
    {
    }

    public override string GetValidatedString(object value)
    {
      string result = base.GetValidatedString(value);

      return result;
    }

    public override BaseFieldControl FieldRenderingControl
    {
      get
      {
        BaseFieldControl ctr = new SPFieldTimeSpanControl();
        ctr.FieldName = this.InternalName;
        return ctr;
      }
    }

Viewing all articles
Browse latest Browse all 11508

Trending Articles