This question is locked. New answers and comments are not allowed.
Hello,
is there a way to get the GridCommand object inside the Update method? I user serverside Sorting and Paging with CustomBinding. After the Update the SortOrder is like on initial load.
Regards,
Timo
is there a way to get the GridCommand object inside the Update method? I user serverside Sorting and Paging with CustomBinding. After the Update the SortOrder is like on initial load.
Regards,
Timo
3 Answers, 1 is accepted
0
Hello Timo,
If you are using the built-in binding you don't need the GridCommand. As noted in the documentation you should just use the GridRouteValues() extension method to retain the grid state:
The GridRouteValues() method is available once you import the Telerik.Web.Mvc.Extensions namespace.
If you must use the grid command - just add a parameter of such type to your action method:
[AcceptVerbs(HttpVerbs.Post)]
[GridAction(GridName="Grid")]
public ActionResult Save(GridCommand command, int id, GridEditMode mode)
Greetings,
Atanas Korchev
the Telerik team
If you are using the built-in binding you don't need the GridCommand. As noted in the documentation you should just use the GridRouteValues() extension method to retain the grid state:
[AcceptVerbs(HttpVerbs.Post)]public ActionResult Save(int id){ ViewData["mode"] = mode; //Create a new instance of the EditableProduct class and set its ProductID property. EditableProduct product = new EditableProduct { ProductID = id }; //Perform model binding (fill the product properties and validate it). if (TryUpdateModel(product)) { //The model is valid - update the product and redisplay the grid. SessionProductRepository.Update(product); //GridRouteValues() is an extension method which returns the //route values defining the grid state - current page, sort expression, filter etc. RouteValueDictionary routeValues = this.GridRouteValues(); return RedirectToAction("EditingServerSide", routeValues); } //The model is invalid - render the current view to show any validation errors return View("EditingServerSide", SessionProductRepository.All());}The GridRouteValues() method is available once you import the Telerik.Web.Mvc.Extensions namespace.
If you must use the grid command - just add a parameter of such type to your action method:
[AcceptVerbs(HttpVerbs.Post)]
[GridAction(GridName="Grid")]
public ActionResult Save(GridCommand command, int id, GridEditMode mode)
Greetings,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
JULIA
Top achievements
Rank 1
answered on 23 Jul 2010, 08:58 AM
My Method:
My Grid:
Now GridCommand.PageSize has always the Value of my Size Property/Column. Why?
Regards,
Timo
public ActionResult _Update( GridCommand command, int id )
My Grid:
<% Html.Telerik().Grid<ViewModels.WeightViewModel>() .Name( "weightGrid" ) .DataKeys( keys => keys.Add( k => k.WeightId ) ) .DataBinding( d => d.Ajax().Select( "_Select", "Weight", new { area = "" } ) .Update( "_Update", "Weight", new { area = "" } ) .Insert( "_Update", "Weight", new { area = "" } ) .Delete( "_Delete", "Weight", new { area = "" } ) ) .ToolBar( t => t.Insert() ) .Columns( c => { c.Bound( p => p.Date ).Width( 100 ).Format( "{0:d}" ); c.Bound( p => p.Value ).Width( 100 ); c.Bound( p => p.Size ).Width( 100 ); c.Bound( p => p.BodyArea ).Width( 150 ).Sortable( false ).ReadOnly( true ); c.Command( commands => { commands.Edit(); commands.Delete(); } ).Width( 120 ); } ) .Sortable() .EnableCustomBinding( true ) .Pageable( p => p.Total( ViewData["total"] != null ? ( int )ViewData["total"] : 0 ) ) .Render(); %>Now GridCommand.PageSize has always the Value of my Size Property/Column. Why?
Regards,
Timo
0
Hello Timo,
That's because the grid is using the same name as a query string parameter ("size"). The Size property is actually the page size of the grid and you can safely give it a fixed value or ignore it.
You can also try decorating your action method with
[GridAction(GridName="
Regards,
Atanas Korchev
the Telerik team
That's because the grid is using the same name as a query string parameter ("size"). The Size property is actually the page size of the grid and you can safely give it a fixed value or ignore it.
You can also try decorating your action method with
[GridAction(GridName="
weightGrid")]Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items