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

[Solved] EditIndexes and PageCount problem

1 Answer 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hadar Kaufman
Top achievements
Rank 1
Hadar Kaufman asked on 13 Jul 2009, 02:04 PM
Hi Telerik,
I want to load my rad grid when all items are in edit mode (in place edit). my page size is 25 records per page, and allowPaging is set to true.
in page pre_render, i do:
for (int i = 0; i < gridChannels.PageCount * gridChannels.PageSize; i++) 
                    { 
                        gridChannels.EditIndexes.Add(i); 
                    } 
When a specific button clicked, or when paging the grid, i want to save the state of the rows. so I want to run over all the edited rows (which are actually all the rows in the grid) and get the values:
foreach (GridEditableItem editedItem in gridChannels.EditItems) 
            { 
// get data.. 

I find 2 problems:

1. Untill i specifically page to the last page of the grid, the pageCount property is set to the page number! meaning it is =1 when i load the grid, even though there are 3 pages to the grid!

2. EditItems property always set to 25, even after i page to page 3, which means the pageCount * page size = 75 so there are 75 edit index in the grid - 75 items in edit mode.

could you please explain why does this behavior occur?

Thanks,
Hadar

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 16 Jul 2009, 12:15 PM
Hi Hadar,

When paging is enable for RadGrid the number of items it contains are equal to the page size, e.g. if PageSize is 25 grid items are 25, or might be less if you are on the last page. The same is true for the EditItems.
Therefore the first code snippet should be:

for (int i = 0; i < gridChannels.PageSize; i++)    
{  
    gridChannels.EditIndexes.Add(i);    

as suggested in this help topic.

Additionally, you can handle the ItemCOmmand or PageIndexChanged to save the data for the edited items in the current page.

I hope this helps.

Greetings,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Hadar Kaufman
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or