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

Adding next/prev buttons to the grid rows

7 Answers 131 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Covertix
Top achievements
Rank 1
Covertix asked on 17 Oct 2012, 06:37 PM
Hi,

I have a rad grid that I create on server-side.
I use paging with virtual item count, and I load data on demand (every time the page index changes, I load the relevant rows, so my grid contains every time number of rows = page size).


I  added 2 buttons, prev and next, that iterates over my grid rows.
It works fine on the first page, but when I want to change the page and select the first item, the page index doesn't change.

Here is my code:

MasterTable.clearSelectedItems();

MasterTable.set_currentPageIndex(NextPageIndex,

true);

MasterTable.rebind();

MasterTable.selectItem(0);

set_currentPageIndex, doesn't make the function

GridReport_PageIndexChanged
to be fired.

 

The rebind calls need data source and there I check the pageIndex, and I get the index before the change..

Do you have any idea what am I doing wrong?
How can I change the page index using java script?

Thanks.


7 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 22 Oct 2012, 09:22 AM
Hello,

 This approach is applicable only in the case of server-side binding. Then you will not need to call the rebind() method on the client because it is specific only for client-side binding.
In order to fire the PageIndexChanged event on the server you have to call the the set_currentPageIndex method with second parameter false:

masterTableView.set_currentPageIndex(1, false)

All the best,
Marin
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Covertix
Top achievements
Rank 1
answered on 23 Oct 2012, 10:56 AM
Hi Marin,

Thanks for your reply.I tried to call: masterTableView.set_currentPageIndex(1, false)
but still PageIndexChanged event on the server didn't fire.

When I call rebind() on client side after set_currentpage, inside needDataSource on server I get the old value in the CurrentPageIndex property...

0
Marin
Telerik team
answered on 25 Oct 2012, 10:28 AM
Hi,

 Another option that you can try is to call the fireCommand method on the client. This way the grid will postback and you should see the new page index in the CurrentPageIndex property. The PageIndexChanged event will also fire approapriately. Here is a sample code:

var masterTable = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
masterTable.fireCommand("Page", "4");
//no need to call rebind() on the client

Greetings,
Marin
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Covertix
Top achievements
Rank 1
answered on 28 Nov 2012, 01:34 PM
Hi Marin,

Thanks for the reply.
I tried this code, and PageIndexChanged  is called, but e.NewPageIndex still holds the old value.

I called:

var masterTable = $find('<%= GridReport.ClientID %>').get_masterTableView();
var NextPageIndex = 0;
masterTable .fireCommand("Page", NextPageIndex);

and I get:

 

 

public void GridReport_PageIndexChanged(object source, GridPageChangedEventArgs e)

{

 
//HERE e.NewPageIndex = 0!!

Session["CurrentPageIndex"] = e.NewPageIndex;

}

Do you have any idea why?
Thanks.

 

 

0
Marin
Telerik team
answered on 03 Dec 2012, 08:10 AM
Hi,

 In case you are using custom paging for the grid make sure the following requirements are fulfilled then the page index should be available in the NeedDataSource event.
More information on how to perform custom paging can also be found in this demo.

All the best,
Marin
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Covertix
Top achievements
Rank 1
answered on 03 Dec 2012, 10:18 AM
I use custom paging.
I checked, and all the requirements are fulfilled, but I get wrong value inside PageIndexChanged event.

What should I do?
Can you give me any code example or refference?
I just want to add simple functionaliity..

Thanks.

0
Marin
Telerik team
answered on 06 Dec 2012, 10:34 AM
Hello,

 You can handle the ItemCommand on the server where the new page index should be accessible in the command arguments. See attached page for further reference.

Regards,
Marin
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 RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Covertix
Top achievements
Rank 1
Answers by
Marin
Telerik team
Covertix
Top achievements
Rank 1
Share this question
or