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

MVC Grid Sort Anchors

3 Answers 42 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.
steve_ba14
Top achievements
Rank 1
steve_ba14 asked on 18 Nov 2011, 09:30 AM
Good morning.

I am working for a client who has implemented four mvc grids on one page.  They have a requirement for a non Javascript version of the page. Your grids work really well , however, I am trying to take the user back to the grid that they sorted on via anchors.

Please could somebody point me in the right direction to append an anchor onto the action links used by the grid for sorting.

Cheers 

3 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 18 Nov 2011, 10:56 AM
Hello Steve,

In order to support sorting with Javascript turned off, you only need to use server binding, nothing special.

http://demos.telerik.com/aspnet-mvc/grid/serverbinding

http://demos.telerik.com/aspnet-mvc/grid/accessibility

Best wishes,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
steve_ba14
Top achievements
Rank 1
answered on 18 Nov 2011, 11:06 AM
Dimo,
Thanks for the quick response.  

If you go to the demo in http://demos.telerik.com/aspnet-mvc/grid/serverbinding and click on a column the url reads  http://demos.telerik.com/aspnet-mvc/grid/serverbinding?Grid-orderBy=ShipAddress-asc

Which as I said before is fantastic.  The problem I have is that my client has 4 Grids on one page in a panel bar. This takes up a lot of real estate. What I am trying to achieve is that when the bottom grid is clicked the URL looks something like  

 http://demos.telerik.com/aspnet-mvc/grid/serverbinding?Grid-orderBy=ShipAddress-asc#Grid4

So then I can implement scroll-to functionality based on anchors rather than JavaScript. 

Cheers

Steven
0
Accepted
Dimo
Telerik team
answered on 18 Nov 2011, 11:57 AM
Hello Steven,

I missed that part in my previous reply, sorry. The described behavior is not provided out-of-the-box, but you can achieve it manually by using server header templates:

http://demos.telerik.com/aspnet-mvc/grid/headerfootertemplates

Your header templates should match the HTML output of normal sortable header cells, i.e.:

<a href="/aspnet-mvc/grid/serverbinding?GridID-orderBy=OrderID-asc#GridID" class="t-link">Column Name</a>

You will have to do some coding work in order to parse the query string parameters, switch the asc and desc strings and add the GridID at two places.

Note that this approach works, but is more or less a hack.

Best wishes,
Dimo
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
Grid
Asked by
steve_ba14
Top achievements
Rank 1
Answers by
Dimo
Telerik team
steve_ba14
Top achievements
Rank 1
Share this question
or