This project is read-only.
Warning: This documentation is quite outdated, but maybe it can help beginners. Please if you have some free time, help me to update it.

1. Examples:

2. Basic usage:

[GridAction(EnableCustomBinding = true)]
public ActionResult GetProducts(GridCommand command)
    var query = ProductService.GetQueryable();
    var queryToCount = ProductService.GetQueryableForCount();
    var gridDataSource = new GridQueryProvider(query, queryToCount);

    var gridHelper =
        new GridCustomBindingHelper<Product, ProductModel>(command, gridDataSource);

    var gridModel = gridHelper.BuildGridModel();

    return View(gridModel);
3. Properties mapping:

The GridModelMapper is not a substitute to AutoMapper, it exists only to map the name (and not the values​​) of the properties between entities and Viewmodels.

However, internally, simple maps are transferred to AutoMapper, so if you do not need any advanced functionally, GMM can be enough, but to enjoy the full power of AutoMapper you must use it, normally the mappings dont overwrite each other. A little confused? Yeah, I think so, but the best way to know if everything is okay is, as always, by testing, and if you find any abnormality, please let me know.

This technique is for special cases where AutoMapper can not provide the mapped property, for example if you are using Custom Type Converters or something similar.
Once you have your types, and a reference to TelerikMvcGridCustomBindingHelper, you can create a map for the properties between the two types.

protected void Application_Start()
    GridModelMapper.CreateMap<Product, ProductModel>()
        .MapProperty(entity => entity.SomeProp, viewModel => viewModel.SomeProp);

    GridModelMapper.CreateMap<Client, ClientModel>()
        .MapProperty(entity => entity.Order.Date, viewModel => viewModel.OrderDate)
        .MapProperty(entity => entity.Order.Total, viewModel => viewModel.OrderTotal);
More examples of mappings can be found in the sample project on the Downloads tab, or direct in the source class ExampleWebApplication.Global.asax.cs on the Source tab.

Last edited Apr 24, 2012 at 11:16 PM by Luis_Fernando, version 24


No comments yet.