Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Sep 27, 2013 @ 18:40
    Matt Brailsford
    0

    Creating dynamic views?

    Hi Guys,

    I was wondering if you could tell me whether it's possible to generate dynamic views in DEWD? I've got a bunch of entities that have a category checkbox list field on them, with the checkbox options coming from another table managed via DEWD. What I want then, is in the view for the main entity be able to select from the "Select view" any one of those categories and have the results filter by it. The columns / query for the view would always be the same, it's just the where clause parameter that changes and it needs to be dynamic from the database.

    Any ideas?

    Cheers

    Matt

  • Sune Bøegh 64 posts 374 karma points
    Sep 28, 2013 @ 11:22
    Sune Bøegh
    0

    Hi Matt,

    I think this should be possible in both versions, but in 1.0 I suspect a custom repository is needed. In 2.0 you should be able to do something like this:

    var dynamicViews = new TableRepository();
    dynamicViews.SetViewBuilder(() =>
    {
        var views = new List<IView>();
        for(var foo = 0;foo<3; foo++)
            views.Add(new TableView(dynamicViews) { Sql = (new SqlStatement("SELECT * FROM table")).AddParameter("param", t) });
        return views;
    });
    

    So basically provide the SetViewBuilder with a delegate that instantiates the views with the different WHERE-statements. In your case some SQL will be needed to get the different categories of course.

    Hope this makes sense.

Please Sign in or register to post replies

Write your reply to:

Draft