>

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)
.EnableAlternateStyle()
.EnableWidthChange(false)
.ItemsContainer(nullExternalContainerType.div, 200)
.StartToolbar(false)
    .RowContainerLevel(ItemContainerLevel.Row)
    .StartParameterColumn(0, 0)
         .CustomColumnClass(GenericCssClasses.NoWrap).EndColumn()//Title
.EndToolBar()
.StartToolbar(false)
.RowContainerLevel(ItemContainerLevel.Row)
.AddButtonToolbar(ShowButtonIn.Both, CommandButtonType.Add,"0").ColumnWidth(100)
     .AppendButton(ShowButtonIn.Both,CommandButtonType.Delete)
.EndButtons()
.EndToolBar()
.SetAsDefault(DefaultScope.Named, "StandardStaticGrid");

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

PrototypeRow.Create()
    .HeaderMarginWidth(21)
    .AddRowCountColumn(true, width: 35)
    .HtmlTitle(ShowTitleIn.Display | ShowTitleIn.Edit)
    .MergeBookmark()
    .Save("StandardGridRow");

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

@{var dBuilder = Html.SimpleGrid(m => m.Directory, DefaultScope.Named,"StandardStaticGrid")
    .Parameters("Customers Directory")
    .AddRowType(truetrue)
    .Load("StandardGridRow")
    .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()
    .EndRowType();
}
@dBuilder.Render()

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).