Control Prototypes

Both the behavior and the Html produced by all Data Moving Plug-in controls may be fine tuned with the help of their fluent interfaces and also with the help of custom templates. However, this configuration effort needs to be done just once, since the developer has the option to save both controls, and rows settings in control and row prototypes that may be re-used on different data.

Prototype definitions are usually inserted in a static method that is called in the global.asax Application_start().

As a first step we create a "fake" HtmlHelper that we will use in the prototype definition:

HtmlHelper<SampleClass> h = SampleClass.CreateHelper();

Then we define the control prototype, with all settings we need:

h.SimpleGrid(m => m.SampleIEnumerableProperty)
    .Container(ExternalContainerType.cssTable, ItemContainerLevel.Column, addJQueryClass: true)
.ItemsContainer(nullExternalContainerType.div, 200)
    .StartParameterColumn(0, 0)
.AddButtonToolbar(ShowButtonIn.Both, CommandButtonType.Add,"0").ColumnWidth(100)
.SetAsDefault(DefaultScope.Named, "StandardStaticGrid");

In case of Items Controls (Grids, TreeViews, Menus, etc.) we define also row prototypes:

    .AddRowCountColumn(true, width: 35)
    .HtmlTitle(ShowTitleIn.Display | ShowTitleIn.Edit)

Now we may define quicly as many grids as we need:

@{var dBuilder = Html.SimpleGrid(m => m.Directory, DefaultScope.Named,"StandardStaticGrid")
    .Parameters("Customers Directory")
    .AddColumn(t => t.Name, canAdjust: true, width: 90, minWidth: 90)
    .AddColumn(t => t.Surname, canAdjust: true, width: 110, minWidth: 90)
    .StartColumn(t => t.EMail).DeclareHidden().EndColumn()
    .StartColumn(t => t.Address).DeclareHidden().EndColumn()

In fact each actual grid definition needs to provide just the columns, and the value of the parameters we defined in the grid prototype (the grid header text).