Dynamic MVC Order Entry Tutorial - Customize Orders List

This tutorial has been updated to version 3.0.
Thur, 4 Sep. 2014 - Chris Perry

If you run the application now, you should see several menu items under the "Dynamic" menu. If you have been following along from our previous tutorials, you should also have an "Admin" menu as well as an "Order Entry" menu.

To clean this up a bit we are going to hide the "OrderLine" menu. We will not need this menu item because we are going to create an orders details page that will show the order lines. Open the OrderLine model and decorate it with the DynamicMenuItemExclude attribute.

We are going to decorate the OrderStatus model with the DynamicMenuItem attribute. Specify "Order Status" for the DisplayName property and "Admin" for the CategoryName property.

Similarly decorate the Order and Product entity so they go under the "Order Entry" menu. Run the application and you should see the "Dynamic" menu has been removed.

Customize Order List Properties

Since we are going to show the order lines on the Order details page we don't need to show it on the Order List page. To hide the order lines column we need to specify the properties we would like to show in the IndexProperties property of the DynamicEntity attribute. Set this property to "OrderDate,CustomerId,OrderStatusId,Total". The order of the properties determines the order they will be displayed on the page.

Customize Display Name

Now that we have order list page displaying the properties we want, we can now customize the table header and cell format. We can use the DisplayName attribute to customize the header. We use the DisplayFormat attribute to customize the format of the OrderDate property.

Specify Default Filtering

We would like to display only new orders by default when a user opens the orders page. To accomplish this we need to create an OrderController. Simply copy and paste the DynamicController to create the OrderController. We will need to customize the Index action. Inside the Index action we will check the query string values and see if a filter already exists. If a filter does not exist we can specify a default filter. Applying a filter is as easy as passing in a dynamic linq clause into the base Index action. If you are unfamiliar with linq and still want to know how to do basic filtering, just put a breakpoint on this method and observe the querystringdictionary while doing manual filtering on the UI.

Hide Edit Hyperlink

We will be creating an Orders Details form that will allow the user to edit specific parts of an order at a time. We will not need to show the edit hyperlink on this page. To hide the edit hyperlink we only need to set the ShowEdit property of the DynamicEntity attribute to false on the Order model.

Customize The Page Header

Now that we have completed the Orders List page we need to make a few customizations to the Create Order Page. We are going to modify the create page to be used to select the customer and navigate to the details page on save. To do this we must first customize the form header. We will need to decorate the Order model with the DynamicHeader attribute. Set the CreateHeader property of DynamicHeader attribute to "Select a Customer".

Modify The Create Page

We now need to set the CreateProperties property of the DynamicEntity attribute to "OrderDate,CustomerId". We can also make the OrderDate field read only by decorating the OrderDate property with UIHint("DynamicEditorReadOnly").

If you run the application now and try to create an order you will get an exception because we are not setting the OrderStatus property. We can overcome this by setting the default value for the OrderStatus by supplying it in the constructor. Set the OrderStatusId to the enum value for a new order.

Modifying The ReturnUrl For The Create Page

We can modify where any dynamic page returns to by passing in a custom ReturnUrl. For the create page this can be done by adding a single line at the beginning of the get method. Notice the use of ScopeIdentity. Dynamic MVC uses ScopeIdentity on the create post action as a placeholder for the primary key value that has yet to be created.

COMMENTS Add Comment
  • This tutorial "Dynamic MVC Order Entry Tutorial - Customize Orders List" doesn't follow the previous one and doesn't work.
    Kevin | 1/29/2016 8:24:48 PM
  • Thank you for letting me know. I am currently beta testing version 3.0. It should be out within the next few weeks. I will update all tutorials during that release.
    Chris | 2/2/2016 3:41:19 AM
  • Uooh!! New Versión!! Nice, i am testing your library and i like very much ;)
    Gambitero | 2/10/2016 4:22:58 PM
  • QueryStringDictionary? Sorry, but where did you get that class/object from? It does not show anywhere? So far, I am very impressed by the tool. Good Job!!!
    Ervin | 2/13/2016 10:43:06 AM
  • Also struggling with the namespace of the QueryDictionary
    Neo | 3/14/2016 12:45:11 AM
  • QueryStringDictionary**
    Neo | 3/14/2016 12:46:33 AM
  • This site is like a clsorsoam, except I don't hate it. lol
    ZzIW6tHK | 3/30/2016 8:24:56 AM
  • You have more useful info than the British had colonies prWI-WeI. http://sksqhjmusts.com [url=http://etflkwcttw.com]etflkwcttw[/url] [link=http://vrxbscitvt.com]vrxbscitvt[/link]
    CAAHYnwxst | 4/8/2016 9:04:49 AM