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

[Solved] Adding querystring parameters to the grid

10 Answers 296 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.
Luis Velez
Top achievements
Rank 1
Luis Velez asked on 12 May 2010, 03:19 PM

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

Sort by
0
Atanas Korchev
Telerik team
answered on 12 May 2010, 03:31 PM
Hello Luis Velez,

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.
0
Luis Velez
Top achievements
Rank 1
answered on 12 May 2010, 04:10 PM
Hi Atanas,

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.




0
Luis Velez
Top achievements
Rank 1
answered on 12 May 2010, 04:45 PM
Hi Atanas,

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.
0
Yitzhak Khabinsky
Top achievements
Rank 1
answered on 12 May 2010, 05:31 PM

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

0
Yitzhak Khabinsky
Top achievements
Rank 1
answered on 13 May 2010, 02:52 PM
Hi Atanas,

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

0
Atanas Korchev
Telerik team
answered on 13 May 2010, 03:22 PM
Hi Yitzhak Khabinsky,

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.
0
Yitzhak Khabinsky
Top achievements
Rank 1
answered on 13 May 2010, 03:46 PM

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

0
Atanas Korchev
Telerik team
answered on 13 May 2010, 04:15 PM
Hi Yitzhak Khabinsky,

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.
0
Accepted
Atanas Korchev
Telerik team
answered on 13 May 2010, 04:53 PM
Hi Yitzhak Khabinsky,

After some testing it appears that implementing this is rather easy:

  1. Open GridHtmlBuilder.cs
  2. Change this:
    new HtmlTag("a").AddClass(UIPrimitives.Icon, "t-refresh")
          .Attribute("href", "#").AppendTo(div);

    to this:
    new HtmlTag("a").AddClass(UIPrimitives.Icon, "t-refresh")
            .Attribute("href",  UrlBuilder.Url(Grid.Server.Select))
            .AppendTo(div);
  3. Open telerik.grid.js
  4. Change this:
    refreshClick: function(e, element) {
        e.preventDefault();
        if ($(element).is('.t-loading'))
            return;
        if (this.isAjax())
            this.ajaxRequest(true);
        else
            location.reload();
    }

    to this:
    refreshClick: function(e, element) {
        if ($(element).is('.t-loading'))
            return;
         
        if (this.isAjax()) {
            e.preventDefault();
            this.ajaxRequest(true);
        }
    }
I have checked those changes in as I think this is the better implementation for server refresh. Thanks for pointing that out!

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
Yitzhak Khabinsky
Top achievements
Rank 1
answered on 13 May 2010, 06:21 PM
Hi Atanas,

Good deal.
Thanks for taking care.

Hopefully, the modifications you made will make into the next Telerik ASP.NET MVC build!

Regards,
Yitzhak
Tags
Grid
Asked by
Luis Velez
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Luis Velez
Top achievements
Rank 1
Yitzhak Khabinsky
Top achievements
Rank 1
Share this question
or