Wednesday, June 29, 2011

Convert a drop down list to autocomplete

The effect o data incremental search is the best choice in relationships where data amount can be large, with SFS Tools this is done in a few minutes just setting a parameter.

image

Step by step

  1. In the configuration file for code generation of “Product” entity change the attribte value of  PerformanceOption to “OnDemand” in the property “ProductModel”.
    image
    <?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="Product" SetName="Products" IsUIVisible="false" GenerateCRUD="true" IsForLocalization="false" IsCustom="false" IsView="false" DefaultProperty="Name">
    <Properties>
    <Property Name="ProductModel" Nullable="true" Order="100.0000" UIRequired="false" Visible="true" VisibleInGrid="true" VisibleInForm="true" PerformanceOption="OnDemand" IsNavigationProperty="true" Type="SFSAdventureWorksModel.ProductModel" MaxLength="0" IsPrimaryKey="false" IsForeignKey="true" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    </Properties>
    </Entity>
    </Entities>
    </SfsModel>

  2. If there are no XML columns involved in this example, the functionality would be finished ...! But unfortunately we must correct an issue (of Entity Framework) in XML property.
  3. Fix a property “Instructions” and “CatalogDescription” that has been mapped automatically how string, but must be changed to  XML int he configuration file and save the changes.
    image
    The file content:
    <?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="ProductModel" SetName="ProductModels" IsUIVisible="false" GenerateCRUD="true" IsForLocalization="false" IsCustom="false" IsView="false" DefaultProperty="Name">
    <Properties>
    <Property Name="Instructions"
    Nullable="true" Order="100.0000" UIRequired="false"
    Visible="true" VisibleInGrid="true"
    VisibleInForm="true"
    PerformanceOption="Fill"
    IsNavigationProperty="false"
    Type="Xml" MaxLength="0" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    <Property Name="CatalogDescription"
    Nullable="true" Order="100.0000"
    UIRequired="false" Visible="true"
    VisibleInGrid="true" VisibleInForm="true"
    PerformanceOption="Fill"
    IsNavigationProperty="false"
    Type="Xml" MaxLength="0" IsPrimaryKey="false" IsForeignKey="false" IsIdentity="false" IsSearchable="false" IsLocalizable="false" IsDataMember="false" IsCustom="false" />
    </Properties>
    </Entity>
    </Entities>
    </SfsModel>

  4. Recreate the code of the user interface project.
  5. Recreate the code of the business rules.
  6. Build the user interface project project.
  7. Test going to address “/SFSAdventureWorks/Products/CreateGen” in the browser and in the field Model write two chars (“cl”) for see the effect of the results founded in the incremental search  to the database.


Conclusion


Converto a field from dropdown list to autocomplete  is very easy with SFS Tools.  But there is another similar practice: LookUp for catalogs more populated and with need for more visible columns in the search.

No comments:

Post a Comment