Rail Sabirov


how to create read only custom field type (as Computed type, for example)

read only - visible only on DispForm and on View.



Re: Read only custom field type

Uwe82


Do you use a custom schema.xml-definition If yes, you have to create a new Field-tag in the Fields-List and make a reference in the ContentType of the schema. For Visibility, you have the attributes

ShowInDisplayForm, ShowInEditForm, ShowInNewForm





Re: Read only custom field type

Rail Sabirov

I don't use schema.xml.

- I create custom field type
- override FieldRenderingControl property, and return my own class (inherit from BaseFieldControl), where I override only Visible property in the following way:

public override bool Visible
{

get

{

if (base.ControlMode == SPControlMode.Display)

{

return base.Visible;

}

return false;

}

set

{

base.Visible = value;

}

}

Calculated field has same RenderingControl.
but my field visible in New and Edit forms.






Re: Read only custom field type

Rail Sabirov

Uwe82 wrote:

Do you use a custom schema.xml-definition If yes, you have to create a new Field-tag in the Fields-List and make a reference in the ContentType of the schema. For Visibility, you have the attributes

ShowInDisplayForm, ShowInEditForm, ShowInNewForm

Uwe82, I try to create schema.xml, but I couldn't install this feature. I use following files:

1) fldtypes_GroupSumField.xml
< xml version="1.0" encoding="utf-8" >
<FieldTypes>
<FieldType>
<Field Name="TypeName">GroupSumField</Field>
<Field Name="ParentType">Text</Field>
.....

2) feature.xml
< xml version="1.0" encoding="utf-8" >
<Feature xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="FF498F1F-9874-48e5-B4A4-A674D7C0B257" Id="1D4E1F0D-EA8E-492f-9A2B-037E299C6AB9" Scope="Site" Title="Some title" >
<ElementManifests>
<ElementManifest Location="elements.xml" />
....

3) elements.xml
< xml version="1.0" encoding="utf-8" >
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Field Name="GroupSumColumn" ID="301738ED-74F7-4aba-9A13-4455A6644170" Type="GroupSumField" ReadOnly="TRUE" DisplayName="GroupSumColumn" />
</Elements>

but when I try to install this feature by: stsadm -o installfeature -filename GroupSumField\Feature.xml, i get error: "Field" elements not supported on Web scope.

I try to use all possible values for Scope attribute for feature, but i got same error.

I understand, that I must use same Type Name in field definition in elements.xml, as I use in custom field type definition in fldtypes_GroupSumField.xml file (bolded and underlined text).

Am I right





Re: Read only custom field type

Uwe82

I didn't try to create custom field types yet, so I can't help you there. But you should take a look at http://msdn2.microsoft.com/en-us/library/ms446361.aspx

I really don't know if you can deploy Field Types via features ...Sorry





Re: Read only custom field type

Rail Sabirov

I find work around:

simply write

public override void OnAdded(SPAddFieldOptions op)
{
this.ShowInEditForm = false;
this.ShowInNewForm = false;
base.OnAdded(op);
}

in custom field type class