This documentation is quite outdated, but maybe it can help beginners. Please if you have some free time,
help me to update it
2. Basic usage:
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.
[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();
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()
.MapProperty(entity => entity.SomeProp, viewModel => viewModel.SomeProp);
.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
, or direct in the source class