locked
Switching On and Off (Field Templates) RRS feed

  • Question

  • User1043796333 posted

    I have some common tables which have many Foreign Keys, let's say: Address, for instance: I store all required addresses of my application in a sigle entity

    So, I have FKs from a lot of entities

    I'd like to switch On/Off some of them depending on my selection of one of the DropdownLists. For insatnce, if I'm registering the address of a Customer then the dropdownlist of Suppliers should be set to [Not Set] because they (customer an supplier) can't have the same address registered in the same record

    Same goes with stores, banks, contact persons, deliveries, sales, stores, etc.

    I'd like to configure my FKs to be set On or Off depending on other selections (I know I have to map this somehow, maybe in the MetaData file), isn't it?

    How can this be done?

     

    Wednesday, September 7, 2011 5:19 AM

Answers

  • User-330204900 posted

    Hi Topolov, same approach use a custom metamodel see A New Way To Do Column Generation in Dynamic Data ... the you could you an attribute to determin which files to show, if you are determing but user type this should be easy if it's based on data then a similar method to cascadign shoudl work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 8, 2011 6:09 AM

All replies

  • User-330204900 posted

    I see what you want you will need to implement a custom metamodel and have a static property you ca put information into to set which filter should be shown.

    Wednesday, September 7, 2011 5:53 AM
  • User1043796333 posted

    I need this not for filtering but for entering data

    I need to switch the FKs of an entity according to the business rules:

    Let's say that I have defined in my MetaData file some property which will indicate the way in which I'd like to customize the behavior of the FKs for every entity, something like:

    [FKActive ="customers", FKInactive"suppliers, banks, stores, contact person"]
    In this case I'll be entering the address of a Customer

    or

    [FKActive ="customers, contact person", FKInactive"suppliers, banks, stores"]
    In this case I'll be entering the address of a contact person of a Customer company

    or

    [FKActive ="banks, contact person", FKInactive"customers, suppliers, banks, stores"]
    In this case I'll be entering the address of a contact person of an specific Bank

    For instance:

    [MetadataType(typeof(addressMetadata))]
    [DisplayName("Address")]
    [DisplayColumn("addres_detail")]   
    [FKActive1 = "customers", FKInactive1 = "suppliers, banks, stores, contactperson"]
    [FKActive2 = "customers, contactperson", FKInactive2 = "suppliers, banks, stores"]
    [FKActive3 = "banks, contactperson", FKInactive3 = "customers, suppliers, banks, stores"]
    public partial class address
    {
    	public partial class addressMetadata
    	{            
              [FilterUIHint("CascadingForeignKey")]
    	  [UIHint("CascadingForeignKey")]
    	  [Filter(Order = 0)]
    	  [Display(Order = 1)][DisplayName("Business")]
    	  public object businesstype { get; set; }
    
    
    
    

    etc

    Wednesday, September 7, 2011 3:06 PM
  • User-330204900 posted

    Hi Topolov, same approach use a custom metamodel see A New Way To Do Column Generation in Dynamic Data ... the you could you an attribute to determin which files to show, if you are determing but user type this should be easy if it's based on data then a similar method to cascadign shoudl work.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 8, 2011 6:09 AM