New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Scaffolding

The Grid HtmlHelper for ASP.NET MVC enables you to use the Kendo UI Scaffolder Visual Studio extension.

The Kendo UI Scaffolder will not include the required UI for ASP.NET MVC files to the project. To automatically achieve this, use the Telerik UI for ASP.NET MVC Visual Studio Extensions. To manually achieve this, refer to this article.

To scaffold the Grid HtmlHelper for ASP.NET MVC:

  1. Create a new ASP.NET MVC application, include an Entity Framework Data Model and add Telerik UI for ASP.NET MVC. If you have already done so, move on to the next step. Otherwise, follow the first four steps described in this article.
  2. Right-click the location where the Grid Controller should be generated. Select Add > New Scaffolded item... from the displayed menu. In this example, you generate it in the Controllers folder.

    UI for ASP.NET MVC A new scaffolded item

  3. Select Kendo UI Scaffolder from the list of available scaffolders.

    UI for ASP.NET MVC Choosing the Kendo UI Scaffolder

  4. On the next screen, you are presented with the Model and Data Context options. Enter the Controller and View names.

    UI for ASP.NET MVC Providing controller and view names in the model options for the Grid

    The Model Class DropDownList contains all model types from the active project. In this example, you list products in the Grid. Select the Product entity.

    UI for ASP.NET MVC Choosing the Model class

    From the Data Context Class DropDownList, select the Entity Framework Data Model class to be used. In this example it is NorthwindEntities.

    UI for ASP.NET MVC Choosing the Data Context class

  5. (Optional) In some scenarios it is convenient to use view model objects instead of the entities returned by the Entity Framework. If this is the case, check the Use an existing ViewModel checkbox. It displays a drop-down list similar to the first one from which you can select the ViewModel that will be used.

    If you have not created it yet, add a new class to the ~/Models folder. Name it ProductViewModel.

    public class ProductViewModel
    {
        public int ProductID { get; set; }
        public string ProductName { get; set; }
        public short? UnitsInStock { get; set; }
    }
    

    Select the ProductViewModel class from the ViewModel Class drop-down list.

    UI for ASP.NET MVC Selecting the ViewModel Class

    The names of the properties in the ViewModel must be exactly the same as the corresponding ones in the Entity. Otherwise, the Kendo UI Scaffolder is not able to link them correctly.

  6. Click the Grid options item on the left.

    UI for ASP.NET MVC Selecting the Grid options

    This screen contains the Grid functionalities that can be configured before scaffolding:

    • DataSource Type—Ajax, Server, or WebApi.
    • Editable—Enable the editing, configure the edit mode—InLine, InCell, or PopUp—and the operations that will be included—Create, Update, Destroy.

      UI for ASP.NET MVC Selecting the Grid editable options

    • Filterable—Enable the filtering of the Grid and select the filter mode.

      UI for ASP.NET MVC Selecting the Grid filterable options

    • Column Menu—Enable the column menu.

    • Navigatable—Enable the keyboard navigation.
    • Pageable—Enable the paging of the Grid.
    • Reorderable—Enable the column reordering.
    • Scrollable—Enable the scrolling of the Grid table.
    • Selectable—Enable the selection and specify the selection mode and type.

      UI for ASP.NET MVC Selecting the Grid selectable options

    • Sortable—Enable the sorting and specify the sorting mode.

      UI for ASP.NET MVC Selecting the Grid sortable options

    • Excel Export—Enable the Excel export functionality.

    • PDF Export—Enable the PDF export functionality.
  7. Click the Events item on the left.

    UI for ASP.NET MVC The Events item in the Grid options

    From this screen, you can select the Grid events to which you want to attach handlers.

    Not all events are supported in the server-binding mode. To see the complete list, refer to this article.

  8. When finished with the Grid configuration, click Add at the bottom. The Grid Controller and the corresponding View are now generated.

See Also

In this article