Customize Menu Items

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.