Sunday, June 26, 2011

Hiding fields

Introduction

One of the simplest ways to make invisible or invisible attributes are certain fields in the model, which directly affects the generated code.

For this example use an entity "Contact."

Prerequisites

  1. Build the sample application.
  2. Create the configuration file for code generation of the entity "Contact".

Steps

  1. Open the file "Contact.sfsedmx" in the folder "SFSAdventureWorksModel " of  the project  "SFS.AdventureWorks.BusinessObjects.EF4" , and set the value “false” in the attribute “VisibleInGrid” of property “AdditionalContactInfo”.
    <Property Name="AdditionalContactInfo" Nullable="true" Order="100.0000" UIRequired="false" Visible="true" VisibleInGrid="false" VisibleInForm="true" PerformanceOption="Fill" IsNavigationProperty="false" Type="String" MaxLength="0" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />

  2. In the property “Suffix” change the value  of “Visible” from “true” to “false”, with this will be visible on the list and on the form.
  3. In the property “EmailPromotion” set the value “true” in  VisibleInForm.
    The content file is:
    <?xml version="1.0" encoding="utf-8"?>
    <SfsModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Entities>
    <Entity Name="Contact" SetName="Contacts" IsUIVisible="false" GenerateCRUD="true" IsForLocalization="false" IsCustom="false" IsView="false" DefaultProperty="Title">
    <Properties>
    <Property Name="AdditionalContactInfo" Visible="true" VisibleInGrid="false" VisibleInForm="true" Nullable="true" Order="100.0000" UIRequired="false" PerformanceOption="Fill" IsNavigationProperty="false" Type="String" MaxLength="0" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    <Property Name="Suffix" Nullable="true" Order="100.0000" UIRequired="false" Visible="false" VisibleInGrid="true" VisibleInForm="true" PerformanceOption="Fill" IsNavigationProperty="false" Type="String" MaxLength="10" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    <Property Name="EmailPromotion" Nullable="false" Order="100.0000" UIRequired="false" Visible="true" VisibleInGrid="true" VisibleInForm="false" PerformanceOption="Fill" IsNavigationProperty="false" Type="Int32" MaxLength="0" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    </Properties>
    </Entity>
    </Entities>
    <Components />
    </SfsModel>

  4. With this, the field “AdditionalContactInfo” will not be in the list but will be visible in the form, the field “Suffix”  will not be visible in the list  and will not visible in the form,  and the field “EmailPromotion” will not be visible in the form but will be visible in the list.
  5. In the user interface project, regenerate the code and build the project.

Conclusion


With SFS productivity tools is very easy to define the visibility of fields specifically from the code generation, but is not the only way, in other posts we will see how to do this code, in business rules.

No comments:

Post a Comment