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

[Solved] Persisting current page and selection on Grid?

5 Answers 119 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 24 Sep 2010, 10:49 PM
I'd like a grid to have the same page and row selected when they come back to the page that they had when they left. I figured I could keep the page and row ID in a cookie and restore them when the grid loads again, but there's a few problems.

For one, I can't find a method to get the current page, only set the page. Also there's no distinct event for changing a page, just row data binding.

Also I don't see a client side method on the grid to set the selected row.

Is what I'm trying to do possible?

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 27 Sep 2010, 08:20 AM
Hi David,

You can use the pageTo() JavaScript method to set the current page on the client-side.

We currently do not support setting the current page from the server side. The good news is that we recently implemented this feature and you will be able to set the current page from the paging configuration. Let me know if you need this functionality and I will send you our latest internal build.

Indeed there is no client-side method to select a row. You can use jQuery to add the required CSS class:

$('#Grid').find('tbody tr:eq(1)').addClass('t-state-selected')

I hope this helps,
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
David
Top achievements
Rank 1
answered on 27 Sep 2010, 05:59 PM
I found the pageTo() method. I was actually looking for a way to get the current page and react to the user switching pages. (In order to save the current page and bring it back later)

I will look into the jQuery statement.
0
Atanas Korchev
Telerik team
answered on 28 Sep 2010, 08:24 AM
Hi David,

 The current page can be retrieved from the currentPage field:

var currentPage = grid.currentPage;

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
David
Top achievements
Rank 1
answered on 01 Oct 2010, 06:45 PM
Thanks. Didn't find that in the documentation. Is there an event that lets you know when a user has switched pages? I would also need this event in order to persist the current page.

(By the way, sorry for not posting this in the Grid forum)
0
Atanas Korchev
Telerik team
answered on 04 Oct 2010, 07:30 AM
Hi David,

 The OnDataBinding event is raised whenever the grid needs to bind - paging, sorting, filtering 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
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
David
Top achievements
Rank 1
Share this question
or