Tuesday, 21 June 2011

More NuGet

I have just put up the the first instalment of my Dynamic Data Extensions this version (V1.0) we have

  • HideColumnIn attribute see A New Way To Do Column Generation in Dynamic Data 4
  • ShowColumnOnlyIn attribute does what it says on the tin shows column in particular page templates
  • Filter attribute (I have only implemented the Order property as yet) this allows you to set the filter order.

Dynamic Data Extensions

Dynamic Data Extensions

Search for DynamicData.Extensions on NuGet

Example Metadata

[MetadataTypeAttribute(typeof(Order.OrderMetadata))]
public partial class Order
{
    internal sealed class OrderMetadata
    {
        public string CustomerID { get; set; }
        public Nullable<int> EmployeeID { get; set; }
        public Nullable<int> ShipVia { get; set; }

        [ShowColumnOnlyIn(PageTemplate.List)]
        [ScaffoldColumn(true)]
        public int OrderID { get; set; }

        public Nullable<DateTime> OrderDate { get; set; }

        [HideColumnIn(PageTemplate.List | PageTemplate.Insert)]
        public Nullable<DateTime> RequiredDate { get; set; }

        [HideColumnIn(PageTemplate.List | PageTemplate.Insert)]
        public Nullable<DateTime> ShippedDate { get; set; }
        public Nullable<decimal> Freight { get; set; }
        public string ShipName { get; set; }
        public string ShipAddress { get; set; }
        public string ShipCity { get; set; }
        public string ShipCountry { get; set; }
        public string ShipRegion { get; set; }
        public string ShipPostalCode { get; set; }

        [Filter(Order=2)]
        public Customer Customer { get; set; }
        [Filter(Order = 1)]
        public Employee Employee { get; set; }
        [Filter(Order = 3)]
        public Shipper Shipper { get; set; }

        public EntityCollection<Order_Detail> Order_Details { get; set; }
    }
}

Here you can see all three custom attributes in action.

  • The HideColumnInAttribute hides columns in page templates (note the use of the ‘|’ OR operator to allows multiple pages to be selected.
  • The ShowColumnOnlyInAttribute does the opposite and only shows columns in selected pages.
  • The FilterAttribute here sets the order to display the filters on the list page (Note there are other properties on Filter that are not yet implemented).

Next up on NuGet are both of my original cascade and my hierarchical cascading field templates.

21 comments:

ICT Consultant said...

Top class code - installed the 13 filters NuGet no problem. The DynamicData NuGet and new Filters NuGet don't install, err msg 'This package (or one of its dependencies) contains PowerShell scripts but the PowerShell 2.0 (or newer) runtime is not installed on this machine.'. Have installed other NuGet packages (ELMAH) w/out issue before and since. Also tried re-installing PowerShell 2.0. Has anyone else experience of this issue? A location from where the dll's can be accessed in the interim would be most useful. Thank you in advance.

Steve said...

Yes sorry about that you will get the same if you tried any of the Scaffolding for MVC or WebForms.

Not sure what the issue is, it's only a simple script to add a using and changne the metamodel type.

Steve

What OS are you running?

Carlos Porras (El Salvador) said...

Steve,
You've said:
About Me

Steve
Newton-le-Willows, Merseyside, United Kingdom
I am currently working as a freelance Aap.Net .... .... shouldn't it say ASP.Net instead?

Steve said...

Hi Carlos, truly I am a bad typer and even worse tester of my own spelling :D

Steve

P.S. fixed it :D

ICT Consultant said...

Hi Steve, thanks for the prompt feedback. OS is XP-SP3.

Steve said...

Hi I will have to setup a VM to test that but I suspect that there is an issue there, can you try installing "T4Scaffolding" this replys heavily on PowerShell if you get the same error then it's a powershell issue on XP.

Steve

ICT Consultant said...

Hi Steve, successfully installed Dynamic Data Extensions on Windows 7 Ultimate OS running Visual Studio 2010 Ultimate. Cheers!

Steve said...

Hi Glad your sorted I will try and see why there is an issue with XP :)

Steve

ICT Consultant said...

Good assertion - "T4Scaffolding" gives the same error on XP sp3 (Visual Studio 2010 Pro).

Steve said...

As I thought do you have anyone else on XP who could test perhaps it's you XP not XP as a whole?

Steve

ICT Consultant said...

Just me; ...if i had a dime for every time a vmware server would have been handy! :) Is it worth pursuit if no-one else (on XP) has had this issue? Great code by the way - very much appreciated.

Steve said...

Thanks again and if I get time I will install VS2010 on my XP-Mode VM and test :)

Steve

Steve said...

Thanks again and if I get time I will install VS2010 on my XP-Mode VM and test :)

Steve

ICT Consultant said...

Hi Steve, got round to completely rebuilding the XP box (with sp3, powershell 2.0, vis studio 2010, Ninite, et al) no gremlins when installing the packages now. :)

Steve said...

Glad your sorted :)

Anonymous said...

Hi there,

Great extension keep up the good work. I was wondering if you intend on implementing the "Group" option for FilterAttribute. Also if you could explain using the group option how you could organise the layout of filters how can you group 4 filters on the left and 4 on the right?

Regards DotnetShadow

Steve said...

Yes I will but it will have to wait till I create my own queryable filter repeater.

Steve

Anonymous said...

Hi Steve,

After I install this nuget package on my project, set metadata for some fields as simple as [Filter(Order = 1)], but it not works on my default QueryableFilterRepeater in the List.aspx. Did I miss something or any other configuration?

Regards,
James

Steve said...

Hi Mark, check your Global.asax.cs you should see it has changed the model to the AdavancedMetsModel where it is initialised if not look at the referenced article to check, I am going to be doing an update soon with much more added, and open source project on codeplex.com


Steve

Boyd said...

Hey Steve just wanted to thankyou for sharing all this. I have used some of your filters before and now am using this for the [Filter(Order)] tags. Used to have to use javascript!

Boyd

Steve said...

thanks Boyd, and there is more to come I am working on an opend source project to give all my bits via NuGet here there will be lots more to come :)

Steve