Stef Heyenrath
Stef Heyenrath

Reputation: 9860

Telerik MVC Grid : Ajax DataBinding posts additional parameter?

I've created a page which support editing multiple entities.
This page is called like: http://localhost/Personnel/EditMultiple?id=2944&id=7

On this page there is a GridView which should list these personnels in a grid. This grid is defined like:

<% Html.Telerik().Grid<Web.Models.PersonnelMiniVM>()
    .Columns(columns =>
    {
        columns.Bound(p => p.Name);
    })
    .DataBinding(d => d.Ajax().Select("_GetPersonnelByIds", "Personnel", new { personnelIds = string.Join(",", Model.PersonnelIds) }))
    .Pageable(page => page.PageTo(Model.Page))
    .Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(p => p.Name)))
    .Render();
%>

But when I look at the URL which is posted to the Personnel Controller, it's like:

http://localhost/Personnel/_GetPersonnelByIds/2944%2c7?personnelIds=7%2C2944&Personnel-size=5

What I don't understand is that why the 2944%2c7 is appended and this also gives me an 401 error when the URL gets too long.

The routing defined in Global.asax is like this:

routes.MapRoute(
    "Default",
    "{controller}/{action}/{id}",
    new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

How to solve this ?

Upvotes: 2

Views: 3558

Answers (1)

Stef Heyenrath
Stef Heyenrath

Reputation: 9860

See this :

http://www.telerik.com/community/forums/aspnet-mvc/grid/mvc3-grid-control-ajax-bound-select-url-has-extra-route-values.aspx

Solution is to clear the id, like:

.DataBinding(d => d.Ajax().Select("_GetPersonnelByIds", "Personnel", new { id= "", personnelIds = string.Join(",", Model.PersonnelIds) }))

Upvotes: 3

Related Questions