Original problem:
Our grid resides in the second tab of a Telerik TabStrip on a page. We allow pagination and sorting of the grid.
When a sort or pagination button is clicked, the grid makes a GET call to the server, passing querystring parameters, such as “<name>-page=<value>”, “<name>-orderBy=<column name>-asc”, etc.
After this GET, page gets refreshed and the very first tab is shown by default, instead of the tab which holds the grid.
Proposed solution:
What we would like to do is to pass our own querystring parameter(s) in the grid API, which in turn will be passed to the TabStrip to make it show the tab with the grid.
Question:
Is this possible to pass our own querystring parameters in addition to the built-in grid querystring parameters?
10 Answers, 1 is accepted
Yes it is possible. Check this forum thread for additional info.
All the best,
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.
I looked at your link and its reference links as well. We are not using Ajax, we are using default server-side Grid binding.
It looks like the only property that exposes the ability to add querystring parameters is the .Select method. Is it only through Ajax that we can add querystring parameters then?
It would be beneficial to introduce a new property or method to the built-in Grid API which would allow to add programatically querystring parameters to any generated links in the Grid (ex. pagination, refresh, sorting, etc ).
Thank you in advance.
We found in the documentation how to add parameters to the querystring with default server-side binding.
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-grid-data-binding-server-binding.html
| <%= Html.Telerik().Grid(Model) |
| .Name("Orders") |
| .DataBinding(dataBinding => dataBinding |
| //Server binding |
| .Server() |
| //Action method |
| .Select("Index", "Home", new {id = (string)ViewData["id"]}) |
| ) |
| .Pageable() |
| .Sortable() |
But it still would be nice, to have a dedicated Grid API property or method for the adding of querystring parameters, regardless of the binding (Ajax, server-side, Web services call, Twitter, Facebook, custom, etc).
Thanks again.
Hi Atanas,
I came across a bug pertaining to the adding additional querystring parameters.
The Grid’s refresh button has just the fence # symbol attached to the URL on the initial page load.
The Grid’s refresh button doesn't add querystring parameters supplied by the
dataBinding.Server().Select(...) method
Column sorting and Grid pagination, both work fine and don’t expose such behavior.
Regards,
Yitzhak
Just for the reference, we are using version 2010.1.416.235
Please confirm that it is a bug with the Grid refresh button and querystring parameters.
Regards,
Yitzhak
Currently the refresh button does not render a link. It is using JavaScript to refresh. We can change if a lot of people start to request it.
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.
Hi Atanas,
I see your point...
We have the same scenario like Luis Velez, i.e. a Grid inside a TabStrip and NOT on a first tab.
So when the Grid is refreshed using its refresh button, the default tab shows up instead of the N-th tab with the Grid on it. And you don't see the tab with the refreshed Grid anymore.
It seems that the only way to handle it is through the passed querystring parameter – tabIndex=<value>
What are your thoughts on the subject?
Regards,
Yitzhak
You can try the solution proposed in this thread.
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.
After some testing it appears that implementing this is rather easy:
- Open GridHtmlBuilder.cs
- Change this:
newHtmlTag("a").AddClass(UIPrimitives.Icon,"t-refresh").Attribute("href","#").AppendTo(div);
to this:
newHtmlTag("a").AddClass(UIPrimitives.Icon,"t-refresh").Attribute("href", UrlBuilder.Url(Grid.Server.Select)).AppendTo(div); - Open telerik.grid.js
- Change this:
refreshClick:function(e, element) {e.preventDefault();if($(element).is('.t-loading'))return;if(this.isAjax())this.ajaxRequest(true);elselocation.reload();}
to this:
refreshClick:function(e, element) {if($(element).is('.t-loading'))return;if(this.isAjax()) {e.preventDefault();this.ajaxRequest(true);}}
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.
Good deal.
Thanks for taking care.
Hopefully, the modifications you made will make into the next Telerik ASP.NET MVC build!
Regards,
Yitzhak