Dynamic Data - Default FieldGenerator

Last post 11-17-2008 4:45 AM by sjnaughton. 11 replies.

Sort Posts:

  • Dynamic Data - Default FieldGenerator

    11-07-2008, 6:41 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    Hi DD Team, I was wondering where does the Default FieldGenrator live, i.e. the one that runs if none is supplied?

    e.g.
    DetailsView1.RowGenerator = new AdavancedFieldGenerator(_table);
    or
    GridView1.ColumnGenerator = new AdavancedFieldGenerator(_table);

    And is there any way of extending it? for instance if it is the DynamicDataManager on the page can this class be inherited and a new Default FieldGenerator implemented?

    Hope this makes some sense? Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Dynamic Data - Default FieldGenerator

    11-07-2008, 9:58 AM
    Answer
    • Contributor
      5,829 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,164
    • AspNetTeam

    Hi Steve,

    It's inside the DDManager, but it's private and can't currently be extended.  However, we're looking to change this.  One idea is to let you pass a generator (or rather a lambda that creates one for a MetaTable) at the time you create your model, and it'll be used as the new default.  This way, no need to change all the pages.

    Thoughts on this?

    thanks,
    David

  • Re: Dynamic Data - Default FieldGenerator

    11-07-2008, 10:08 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    davidebb:
    One idea is to let you pass a generator (or rather a lambda that creates one for a MetaTable) at the time you create your model, and it'll be used as the new default. 

    That's exactly where I was going with this as it would make adding column level security to an existing site real easy.

    The other thing i was thinking of was chaining the colum generators i.e. the input for one is the output for the next so instead of passing in the table you waout pass in the result of the last query and the query would always be a IEnumerable of columns, it's just a thought Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Dynamic Data - Default FieldGenerator

    11-07-2008, 2:20 PM
    • Contributor
      5,829 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,164
    • AspNetTeam

    One issue is tha IAutoFieldGenerator deals with DynamicFields, not MetaColumn.  Maybe the right thing to do is to not use that interface at the model level, and instead stick to using IEnumerable<MetaColumn>.  This way it becomes applicable to scenarios that don't use GridView/ListView.

    David

  • Re: Dynamic Data - Default FieldGenerator

    11-07-2008, 2:21 PM
    Answer
    • Contributor
      5,829 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,164
    • AspNetTeam

    Sorry, I meant GridView/DetailsView, which are the two controls that use DynamicFields.

  • Re: Dynamic Data - Default FieldGenerator

    11-08-2008, 7:59 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    That sounds more the thing David, I hope that something of this sort comes along as it will make adding global changes without messing about with each PageTemplate and CustomPage Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: Dynamic Data - Default FieldGenerator

    11-10-2008, 5:12 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    Having thought about it David I think that the Lambda should return a List of DynamicFields as in the IAutoFieldGenerator as all you will be able to do by returning an IEnumberable is drop and sort fields and one of the things I you would want to do is control the DynamicField i.e. change its mode make it ReadOnly etc.

    I don't think this would be a major drawback, as you may want to sort or drop fields based on some rules so chaining the lambdas wont be as important as having a centralized FieldGenrator.

    Hope I'm still making sense Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Dynamic Data - Default FieldGenerator

    11-14-2008, 11:29 AM
    • Contributor
      5,829 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,164
    • AspNetTeam

    That's a good point Steve.  The drawback of using DynamicFields is that it's specific to GridView/DetailsView, and we'd like the generator to apply to other situations as well (e.g. 3rd party controls, ListView, non-WebForms scenarios).  We could still use DynamicFields simply as a way to help the relevant data, but they could not be used directly outside of GridView/DetailsView.  The alternative is to create a new class that holds the data (MetaColumn, mode).

    But either way, I agree that just the MetaColumn is insufficient for the full range of scenarios.

    David

  • Re: Dynamic Data - Default FieldGenerator

    11-14-2008, 1:18 PM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    What I'm thinking is based on the metadata being read-only if it were read-write then perhaps you could set or add attributes on the MetaColumn sutch as readonly and then if the default field generator could set the mode to  

    DataBoundControlMode.ReadOnly

    then you could have your security per column Big Smile

    well I hope Wink

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Dynamic Data - Default FieldGenerator

    11-17-2008, 2:04 AM
    • Contributor
      5,829 point Contributor
    • davidebb
    • Member since 06-11-2002, 12:31 PM
    • Redmond, WA
    • Posts 1,164
    • AspNetTeam

    Note that there is only a single instance of each MetaColumn/MetaTable running in the app domain, so if you were to dynamically change their readonly flag for each request, you'd get random conflicts between threads stepping on each other.  Unless I totally misunderstood your comment, which is quite possible! :)

    David

  • Re: Dynamic Data - Default FieldGenerator

    11-17-2008, 3:38 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    Ah! so you'd still need a FieldGenerator to do the read only on fields Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Dynamic Data - Default FieldGenerator

    11-17-2008, 4:45 AM
    • Star
      12,372 point Star
    • sjnaughton
    • Member since 04-29-2008, 1:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,574
    • TrustedFriends-MVPs

    Well after this chat David I'm beginning to think that the IAutoFieldGenerator is the most powerfull tool to use as a Default FieldGenerator althought the flexibility of returning an IEnumerable still has it's merits.

    I guess we'll just have to wait an see what you and the team come up with Big Smile

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
Page 1 of 1 (12 items)