Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

GridView - EditFormTemplate with strong-typed FormLayout

$
0
0

You can find how to place a FormLayout inside the EditForm template in the A simple implementation of FormLayout inside EditFormTemplate example. But, the problem in this example is that the FormLayout is not strong-typed. The advantages of the strong-typed approach:

1. You can use client-side validation;

2. If you change the name of a model property, you will easily find places where you need to change that name as well when compiling your project.

The main idea of this example is to create a separate partial view with a FormLayout. Since the grid requires a model that represents a list of data items, but to be strong-typed, a FormLayout should be bound to a single item, this approach will allow us to use a strong-typed model in the partial view with a FormLayout and pass a particular item from the Grid partial view to the FormLayout partial view.

Take a note at how the "Update" and "Cancel" button client-side clicks are handled:

[C#]
btnSettings.ClientSideEvents.Click=string.Format("function(s, e) {{ {0}.UpdateEdit(); }}",settings.Name);

 

[VB.NET]
btnSettings.ClientSideEvents.Click = String.Format("function(s, e) {{ {0}.UpdateEdit(); }}", settings.Name)

 

As you can see, instead of a hard-coded grid view extension name, the settings.Name property is used. This will ensure that the corresponding client-side methods will be precisely executed for our grid view extension.


Viewing all articles
Browse latest Browse all 7205

Trending Articles