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

Databinding at OnNeedDataSource & CurrentPageIndex problem

2 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Juan Angel
Top achievements
Rank 1
Veteran
Juan Angel asked on 13 Oct 2008, 04:58 PM
Please study this scenario:
  • Bind grid data at OnNeedDataSource event with a simple datatable.
  • RadGrid allow paging, with PageSize = 10 items (for example)
  • At top of grid some controls (textboxes, comboboxes, etc.) for filter grid rows.
Well, now interact:
  1. Launch search and found 1000 items (10 items per 10 pages).
  2. Go to last page.
  3. Launch search and found 20 items (10 item per 2 pages)
  4. Oh my god!!! Nothing ??? No rows returned ??? How it's possible? If I set a breakpoint at NeedDataSource event, grid datasource has 20 rows !!!
The secret is CurrentPageIndex, when we go to last page property value is 10, but when launch the second search (Rebind()) the data is binded, but CurrentPageIndex isnĀ“t reset, the value still at 10 but new datasource only has 2 pages.

The solution is easy, after launch search set manually CurrentPageIndex to:
a) First page
b) Last page
c) Last page, only if the new datasource has less rows
d) ...

I think that CurrentPageIndex must be updated in this cases to last page (or first page) of new datasource (equal to in pager mode advanced) or at least throw and exception, because find this little "error" is difficult (i spent a lot of minutes).

2 Answers, 1 is accepted

Sort by
0
Hiren
Top achievements
Rank 1
answered on 15 Oct 2010, 08:20 AM
I am also getting the same issue with the telerik grid. When I reserch on my grid with different search criteria it shows "no record found".
While data source has the records.

Any solution why grid maintains its currentpageindex on databind method.
0
Dimo
Telerik team
answered on 20 Oct 2010, 03:40 PM
Hello,

Indeed, currently RadGrid does not reset its CurrentPageIndex during filtering. We will research for a way to fix this for some of the next versions of the control. Sorry about the temporary inconvenience. You can subscribe to the RadGrid's ItemCommand event, check whether e.CommandName == RadGrid.FilterCommandName and reset the page index.

Sincerely yours,
Dimo
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
Grid
Asked by
Juan Angel
Top achievements
Rank 1
Veteran
Answers by
Hiren
Top achievements
Rank 1
Dimo
Telerik team
Share this question
or