This is a migrated thread and some comments may be shown as answers.

[Solved] Getting the model object in a Custom Binding Grid Ajax Controller.

1 Answer 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Juan Pablo Perez
Top achievements
Rank 1
Juan Pablo Perez asked on 07 Oct 2010, 09:17 PM
I'm using the a custom binding grid in a View. The model contains some values to filter the data of the grid. The problem is that I can't get the value in the Ajax Controller of the Custom Binding Grid.

Here is part of the code:

View:
<%=Html.Telerik().Grid<tfnGetAllMastersCountriesResult>()
    .Name("Grid")
    .Columns(columns =>
        {
            columns.Bound(o => o.Code).Width(100);
            columns.Bound(o => o.ISO3Code).Width(100);
            columns.Bound(o => o.CDH).Width(100);
            columns.Bound(o => o.Description).Width(400);
            columns.Bound(o => o.DisabledDate).Width(100);
            columns.Bound(o => o.Id)
            .ClientTemplate(
                "<input type='button' value='Edit' onclick='updateRecord(\"<#= Id#>\")' />")
            .Title("Commands");
        }
    )
    .DataBinding(dataBinding => dataBinding.Ajax()
        .Select("AjaxGrid", "Countries",  new { model = Model } )
    )
    .Pageable(settings => settings
        .PageSize(Model.PageSize)
        .Total(Model.Total)
        .PageTo(Model.Page)
    )
    .EnableCustomBinding(true)
    .Sortable()
    .Filterable()
    .Scrollable()  
%>

Controller:
[GridAction(EnableCustomBinding = true)]
public ActionResult AjaxGrid(GridCommand command, ViewModelCountries model)
{
    return Json(new GridModel
                    {
                        Data = GetModels(command),
                        Total = _repository.Count
                    });
}

The value of model parameters is always null. Could anybody tell what is the way to get this.

Thank you very much.

Juan

1 Answer, 1 is accepted

Sort by
0
Sean
Top achievements
Rank 1
answered on 28 Mar 2011, 03:12 AM
I'm pretty sure you can't. If you need values you'll have to do some client side coding:

http://www.telerik.com/community/forums/aspnet-mvc/grid/code-sample-sending-additional-filters-with-ajax-binding.aspx 
Tags
Grid
Asked by
Juan Pablo Perez
Top achievements
Rank 1
Answers by
Sean
Top achievements
Rank 1
Share this question
or