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

Grid Querystring Parameters with hyphens are unfriendly to Views

4 Answers 46 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.
Shane Milton
Top achievements
Rank 2
Shane Milton asked on 06 May 2010, 09:40 PM
When you have a grid with prefixes turned on, the querystring parameters that are generated end up having hyphens in the name. This becomes VERY unfriendly to Views who wish to use these parameters for server-side functionality (sort/paging/filtering/etc.).

How can we change this behavior or work around it? I have found a workaround that works for strings but nothing that allows me to keep the data as strongly-typed data (i.e. bringing in the page number as an integer 1 rather than as a string "1").

For what it's worth, my work-around is this:

        protected override void OnActionExecuting(ActionExecutingContext filterContext) 
        { 
            var keys = filterContext.HttpContext.Request.QueryString.AllKeys.Where(k => k.Contains('-')); 
            foreach (var key in keys) 
            { 
                filterContext.ActionParameters[key.Replace('-', '_')] = filterContext.HttpContext.Request.QueryString[key]; 
            } 
 
            base.OnActionExecuting(filterContext); 
        } 
 

4 Answers, 1 is accepted

Sort by
0
Shane Milton
Top achievements
Rank 2
answered on 06 May 2010, 09:41 PM
For additional discussion and examples, I've posted this question in another form here.
0
Shane Milton
Top achievements
Rank 2
answered on 06 May 2010, 09:48 PM
Well, that figures. As soon as I post this on here, I get a work-around in my StackOverflow question. :-P

        public ActionResult Index( 
            [Bind(Prefix = "BusinessGrid-page")] int businessGridPage = 1
            [Bind(Prefix = "BusinessGrid-orderBy")] string businessGridOrderBy = "Name-asc"
            [Bind(Prefix = "BusinessGrid-filter")] string businessGridFilter = ""
            int pageSize = 25
        { 
            {...} 
        } 
 

0
Atanas Korchev
Telerik team
answered on 07 May 2010, 07:05 AM
Hi Shane Milton,

You can easily avoid that if you do PrefixQueryStringParameters(false). Prefixing is vital if you have more than one grid in your page and use server binding. Without it both grid would page, sort etc.

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.
0
Shane Milton
Top achievements
Rank 2
answered on 07 May 2010, 05:18 PM
Atanas, that's the exact problem and why I had to turn prefixes back on - I need multi-grid support. The [Bind] solution works great for us, though.
:-)

-Shane
Tags
Grid
Asked by
Shane Milton
Top achievements
Rank 2
Answers by
Shane Milton
Top achievements
Rank 2
Atanas Korchev
Telerik team
Share this question
or