Telerik Extensions for ASP.NET MVC

Version Q2 2012, released 06/07/2012

Server Editing

Edit mode


Button type

Product nameUnit priceUnits in stockLast supplyDiscontinuedCommands
Chai$18.00396/19/2013Edit
Chang$19.00176/19/2013Edit
Aniseed Syrup$10.00136/19/2013Edit
Chef Anton's Cajun Seasoning$22.00536/19/2013Edit
Chef Anton's Gumbo Mix$21.3506/19/2013Edit
Grandma's Boysenberry Spread$25.001206/19/2013Edit
Uncle Bob's Organic Dried Pears$30.00156/19/2013Edit
Northwoods Cranberry Sauce$40.0066/19/2013Edit
Mishi Kobe Niku$97.00296/19/2013Edit
Ikura$31.00316/19/2013Edit
Displaying items 1 - 10 of 77

About this example ASPXRazor

This example shows the in-line data editing feature of Telerik Grid for ASP.NET MVC. In this example the grid is using server binding.

To enable editing you need perform the following:

  1. Define a command column for the "Edit" and "Delete" commands:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .Columns(columns =>
            {
                columns.Bound(c => c.ContactName).Width(360);
                columns.Bound(c => c.Country).Width(120);
                columns.Bound(c => c.Address).Width(200);
                columns.Bound(c => c.BirthDay).Width(130).Format("{0:d}");
                columns.Command(commands =>
                {
                    commands.Edit();
                    commands.Delete();
                }).Width(200);
                
            })
    %>
    
  2. If you want to enable inserting of new records configure the grid toolbar:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .Columns(columns =>
            {
                //omitted for brevity
            })
    %>
    
  3. Specify the property which uniquely identifies the data record. In this case it is CustomerID:
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .DataKeys(keys => keys.Add(c => c.CustomerID))
            .Columns(columns =>
            {
                //omitted for brevity
            })
    
  4. Specify the action methods which will delete, insert or save data records.
    <%= Html.Telerik().Grid(Model)
            .Name("Grid")
            .ToolBar(commands => commands.Insert())
            .DataKeys(keys => keys.Add(c => c.CustomerID))
            .DataBinding(dataBinding => dataBinding
                .Server()
                   .Select("EditingServerSide", "Grid")
                   .Insert("Insert", "Grid")
                   .Update("Save", "Grid")
                   .Delete("Delete", "Grid"))
            .Columns(columns =>
            {
                //omitted for brevity
            })
    

Interested in HTML5 and mobile-powered ASP.NET MVC apps?

Experience the next generation UI and framework for ASP.NET MVC development by downloading trial evaluation copy of Kendo UI Complete for ASP.NET MVC. Jumpstart your development with the available learning resources.

The differences between Telerik MVC Extensions and Kendo UI Complete for ASP.NET MVC, and their licensing models are explained here and here.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: