This question is locked. New answers and comments are not allowed.
Hi,
We're using a grid with paging and custom data binding. We also provide a route name to the databinding select.
This works fine, except one thing, the url's appends a querystring of the route data values which we don't need (or want) to show.
Here's an example:
As you can see, I'm using a route name to select from the server - "CmsRoute".
This is a custom route that we use to make our url's look something like this:
The last part is extracted with regex in our custom MvcRouteHandler. And to make everything work, we add some stuff to the RequestContext.RouteData.Values;
Later on we use these values to find what we need.
Now, as I said before, the Grid is appending these route data values as a querystring;
Maybe this is by design, but how about an option or delegate where we can build the url?
Or an option to disable the merging?
Or is there another way of doing this, I mean, remove the querystring values we don't need?
Regards,
Mario
We're using a grid with paging and custom data binding. We also provide a route name to the databinding select.
This works fine, except one thing, the url's appends a querystring of the route data values which we don't need (or want) to show.
Here's an example:
<% Html.Telerik().Grid(Model) .Name("ProductsGrid") .PrefixUrlParameters(false) .EnableCustomBinding(true) .DataBinding(d => d.Server().Select("CmsRoute") .Pageable(s => s.Total(Model.TotalItems).PageSize(Model.PageSize)) .Sortable() .Columns(columns =>
...
).Render(); %>As you can see, I'm using a route name to select from the server - "CmsRoute".
This is a custom route that we use to make our url's look something like this:
/Something/Something_else/123456.htmlOR/Whatever/how/many/times/you/want/123456.htmlThe last part is extracted with regex in our custom MvcRouteHandler. And to make everything work, we add some stuff to the RequestContext.RouteData.Values;
protected override System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext){ // extract id and get other stuff .... requestContext.RouteData.Values.Add("cmsid", cmsid); requestContext.RouteData.Values.Add("linkedobjectid", linkedobjectid); requestContext.RouteData.Values.Add("actionid", actionid); requestContext.RouteData.Values.Add("viewname", view.ViewName); requestContext.RouteData.Values.Add("controller", controller.ControllerNameShort); requestContext.RouteData.Values.Add("action", action.ActionName); return base.GetHttpHandler(requestContext);}Later on we use these values to find what we need.
Now, as I said before, the Grid is appending these route data values as a querystring;
public class GridUrlBuilder{ / ..... /
public RouteValueDictionary PrepareRouteValues(RouteValueDictionary routeValues) { RouteValueDictionary result = new RouteValueDictionary(routeValues); result.Merge(grid.ViewContext.RouteData.Values, false);// Here's where the "magic" happens. if (grid.EnableCustomBinding) { result[grid.Prefix(GridUrlParameters.PageSize)] = grid.PageSize; } foreach (string key in grid.ViewContext.HttpContext.Request.QueryString) { if (key != null && !result.ContainsKey(key)) { result[key] = grid.ViewContext.HttpContext.Request.QueryString[key]; } } return result; }}Maybe this is by design, but how about an option or delegate where we can build the url?
Or an option to disable the merging?
Or is there another way of doing this, I mean, remove the querystring values we don't need?
Regards,
Mario