Telerik Controls with ASP.NET MVC: Does this violate the MVC model?

  • Will using Telerik MVC Controls with ASP.NET MVC violate MVC model?

  • And if not, what kind of performance (compared to features and development speed) will Telerik use to control manually HTML coding?

+5
source share
5 answers

Since I am the one who created this demo, I think I can share my opinion. This sample application does not violate the principles of MVC for me. RadControls do not rely on ViewState or postbacks in MVC applications (you can check the generated output to see for yourself - no __doPostBack or __VIEWSTATE). In fact, you need to write code to snap the grid or fill the menu, but still the code is in the view (ASPX) and is completely connected with the presentation (again, this is just my opinion, so I can be wrong).

, : ( postback) MVC. . , - RadControls ASP.NET MVC.

+12

, , , . , - Telerik MVC, Menu, TabStrip PanelBar, TON ( /tabstrip/etc , (, ) CSS). , RadControls MVC - - ASPNET.

, Grid, , . MVC, , Grid, "" "" URL-, MVC. , , .

, .

-Todd

+3

, PostBack WebForms MVC. , , MVC. / WebForms MVC- -, , .

, Telerik, - MVC: , , HTML, . , Telerik MVC. Javascript ViewUserControls, .

0

telerik MVC. , (http://telerikwatch.com/2009/01/telerik-mvc-demo-app-now-available.html), , viewstate/postback. telerik, MVC , , ...

0

, , "Telerik ASP.NET MVC control" - , datepickers, grid, , . MVC. . , , , , , MVC.

, , MVC Model-View-Controller. Model, , , , , , Telerik, .., , , . , , , MVC. , MVC, , , "" MVC.

:

VIEW:

@model MyViewModel

<%= Html.Kendo().DateTimePickerFor(model => model.ExpirationDate)
    .Name("datetimepicker")
    .Value(model.ExpirationDate)        
%>

VIEWMODEL: ( )

public MyViewModel() {
    public DateTime ExpirationDate { get; set; }
}

CONTROLLER:

public ActionResult Index(int id)
{
    var data = dataContext.SomeTable.Where(e => e.ID == id).FirstOrDefault();
    // return View(data); // this would allow you to use @model SomeTable 
    // in your view, and not require a ViewModel, but returns the whole 
    // record for the given ID

    // ViewModels allow you flexibility in what you return
    MyViewModel mvm = new MyViewModel();
    mvm.ExpirationDate = data.ExpirationDate;
    return View(mvm);
}

Telerik / , ( ). - , , , , , , , - , , , Filterable(), . , , , DataColumns DataTable, , OnDataBound ( , ), , , , , , :

<%: Html.Kendo().Grid<Models.ViewModels.MyViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ExpirationDate).Format("MM/DD/YYYY");
    })
    .HtmlAttributes(new { style = "height: 380px;" })
    .Scrollable()
    .Sortable()
    .Filterable()
    .Pageable(pageable => pageable
        .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Customers_Read", "Grid"))
        .Create(create => create.Action("Customers_Create", "Grid"))
        .Update(update=> update.Action("Customers_Update", "Grid"))
        .Delete(delete => create.Action("Customers_Delete", "Grid"))
    )
 %>

"" , public ActionResult Index() public Customers_Read([DataSourceRequest] DataSourceRequest request) {}, data .ToDataSourceResult(). 3 , , , , - dataContext.SaveChanges() . , . - , .

Just take a look at the code examples here to give a better idea: http://demos.telerik.com/aspnet-mvc/

0
source

All Articles