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

RadGrid Paging Questions

2 Answers 144 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 02 Sep 2008, 07:00 PM
Telerik Support:

I have been using the MasterTableView to page through all pages to get all row/column data in each cell.

It looks to me that when you are paged to page 2 of 2 the first page shows the records for the page 2 on the first page. That is page one now has the data from page two and page two has the data from page one.

Example:  I have a grid with 10 record in page one and 1 record on page 2. Paging is set for 10 record per page.

When I cycle through the pages in order of page 1 thenn page 2 the one record from page 2 is printed and then the 10 records from page 1 are printed.

So If I take a snap shot of the records while on page 1 of 2 then take another snap shot when I'm on page 2 of 2 the snap shots are different.

Q1] Please explain how your paging works internally so I can pull the data consistantly no matter how the paging is shown in the grid.

Q2] If you have more then 2 pages in grid then how does the data look for say 3 or 4 pages and page 3 is shown??

Snap Shot format of data is control name, comma, data.
With grid data I added the _PgXRowXColX to the end of the control...

Data (Snap shot one):

ctl00_caseNumberTextBox_textControlRadTextBox:,
ctl00_DefaultContent_caseNumberYearTextBox_numericControlTextBox:2008,
ctl00_DefaultContent_caseNumberCaseTypeTextBox_specialTextControlTextBox:DR,
ctl00_DefaultContent_caseNumberCountyCodeTextBox_numericControlTextBox:24,
ctl00_DefaultContent_caseNumberSeqNoTextBox_numericControlTextBox:00700,
ctl00_DefaultContent_eventDropDownList_requiredDropDownList:Checked In-358,
ctl00_DefaultContent_destinationDropDownList_dropDownListControl:---,
ctl00_DefaultContent_accessTextBox_specialTextControlTextBox:Public,
ctl00_DefaultContent_signatureCheckBox:False,
ctl00_DefaultContent_signOutTextbox_requiredTextControlTextBox:,
ctl00_DefaultContent_commentsTextBox_multilineTextControlTextBox:,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col2:8/22/2008 2:34:17 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col3:Padmakar,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col4:2323,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col5:Public Viewing,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col6: ,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col1:Checked Out,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col2:8/22/2008 1:32:49 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col3:jerry,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col4:Fred Flintstone,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col5:Public Viewing,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row2Col6:Fred was here.,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col2:7/30/2008 4:36:30 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col4:fasdfsa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row3Col6:fasdfasfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col2:7/30/2008 4:36:20 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col3:jerry,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row4Col6:asdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col2:7/30/2008 4:35:00 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col4:fadsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row5Col6:afdsfasfdas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col2:7/30/2008 4:34:50 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col5:Judge's Chambers,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row6Col6:asdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col2:7/30/2008 4:34:37 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row7Col6:asdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col2:7/23/2008 9:25:18 AM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col4:fadsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row8Col6:asdfasdfasf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col2:7/22/2008 6:36:04 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col4:afsdsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row9Col6:afsdasdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col2:7/22/2008 6:35:52 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col4:fasdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col5:Public Viewing,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row10Col6:afsdfaf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col2:7/22/2008 6:30:54 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col4:fadssaf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col6:asdfasfas,

Data (Snap shot two):

ctl00_caseNumberTextBox_textControlRadTextBox:,
ctl00_DefaultContent_caseNumberYearTextBox_numericControlTextBox:2008,
ctl00_DefaultContent_caseNumberCaseTypeTextBox_specialTextControlTextBox:DR,
ctl00_DefaultContent_caseNumberCountyCodeTextBox_numericControlTextBox:24,
ctl00_DefaultContent_caseNumberSeqNoTextBox_numericControlTextBox:00700,
ctl00_DefaultContent_eventDropDownList_requiredDropDownList:Checked In-358,
ctl00_DefaultContent_destinationDropDownList_dropDownListControl:---,
ctl00_DefaultContent_accessTextBox_specialTextControlTextBox:Public,
ctl00_DefaultContent_signatureCheckBox:False,
ctl00_DefaultContent_signOutTextbox_requiredTextControlTextBox:,
ctl00_DefaultContent_commentsTextBox_multilineTextControlTextBox:,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col2:7/22/2008 6:30:54 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col4:fadssaf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg1Row1Col6:asdfasfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col1:Checked Out,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col2:8/22/2008 1:32:49 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col3:jerry,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col4:Fred Flintstone,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col5:Public Viewing,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row1Col6:Fred was here.,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col2:7/30/2008 4:36:30 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col4:fasdfsa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row2Col6:fasdfasfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col2:7/30/2008 4:36:20 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col3:jerry,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row3Col6:asdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col2:7/30/2008 4:35:00 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col4:fadsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row4Col6:afdsfasfdas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col2:7/30/2008 4:34:50 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col5:Judge's Chambers,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row5Col6:asdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col2:7/30/2008 4:34:37 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col4:fasdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row6Col6:asdf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col2:7/23/2008 9:25:18 AM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col4:fadsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row7Col6:asdfasdfasf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col2:7/22/2008 6:36:04 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col4:afsdsfa,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row8Col6:afsdasdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col2:7/22/2008 6:35:52 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col4:fasdfas,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col5:Public Viewing,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row9Col6:afsdfaf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col1:Checked In,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col2:7/22/2008 6:30:54 PM,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col3:rkunisetty,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col4:fadssaf,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col5:Courtroom,
ctl00_DefaultContent_checkOutHistoryGridView_Pg2Row10Col6:asdfasfas,

Code Sample:

case "RADGRIDVIEW":

{

        RadGridView rgv = (RadGridView)childControl;

        int currentPageIndex = rgv.CurrentPageIndex;

        for (int page = 0; page <= Math.Min(rgv.MasterTableView.PageCount - 1, rgv.CurrentPageIndex); page++)

        {

                int row = 1;

                foreach (GridDataItem dataItem in rgv.MasterTableView.Items)

                {

                        int col = 1;

                        foreach (GridColumn column in rgv.MasterTableView.RenderColumns)

                        {

                                if (column is GridBoundColumn)

                                {

                                        controlValues.Append(rgv.ClientID);

                                        controlValues.Append(

"_Pg" + (page + 1) + "Row" + row + "Col" + col);

                                        controlValues.Append(

":");

                                        controlValues.Append(dataItem[column.UniqueName].Text);

                                        controlValues.Append(

",");

                                        col++;

                                }

                    }

                    row++;

            }

                    //this will fire Page command and move to the next page

                    rgv.MasterTableView.GetItems(

GridItemType.Header)[0].FireCommandEvent("Page", "Next");

    }

        rgv.CurrentPageIndex = currentPageIndex;

// reset to the current page

        rgv.Rebind();

        break
;

}//End of case.

End of code.

Q3] Can you show how to FireCommandEvent() event for a specific page like page 3?...
I tried to use the integer value casted to a string...

rgv.MasterTableView.GetItems(GridItemType.Header)[0].FireCommandEvent("Page", myInt.ToString());

Please answer all three questions.

Thanks! JerryM

2 Answers, 1 is accepted

Sort by
0
Rama
Top achievements
Rank 1
answered on 03 Sep 2008, 01:54 PM
Everyone,

The main thing to notice is with the first snapshot the page 1 has 10 records and page 2 has one record all with 6 data items each row.  Data is between the colon and the comma.

In the second snapshot the pager is moved to page two. And the data now has one row (6 data items) on page 1 and page 2 now has ten rows. So, the paging to page 2 caused the data to swap places. 

All I'm looking for is a consistent way to export the controlID/row/column identifier and the associated cell data to a string. Not to a file (pdf, csv, etc.).

I want to be able to in the future to maybe selectively remove one cell or one column from my output string base on some custom code.

I need to be able to extract this identifier/data for each cell in the grid (RadGrid).

The code I initially posted was the standard way someone would do it with little knowledge of your grid but it has issues paging as well.

This code was provided basically from Telerik.  This code work fine if one page one of the list of pages.  However, if you have more than one page and the pager has moved the page to any page other then the original page one.  The data is moved around within the grid. 

Q4] Does the RadGrid control not have a collection that you can consistantly pull the data from in row 1, row 2 row 3 order until the last row????

thanks in advance! JerryM
0
Sebastian
Telerik team
answered on 05 Sep 2008, 10:12 AM
Hi JerryM,

Onto your questions:

  1. If you use advanced binding through the NeedDataSource event or a data source control, the internal paging mechanism of the control should work without issue and you will be directed to the relevant page automatically when clicking the arrows/numbers in the pager item.
    In case you would like to implement custom paging, review the implementation/description of this online demo which illustrates the approach:

    http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/CustomPaging/DefaultCS.aspx
  2. I believe point 1 covers this paragraph as well.
  3. The FireCommandEvent method should be invoked for the GridPagerItem instance in this case, namely:

    rgv.MasterTableView.GetItems(GridItemType.Pager)[0].FireCommandEvent("Page", "2");

    or 

    rgv.MasterTableView.GetItems(GridItemType.Pager)[1].FireCommandEvent("Page", "2");

    depending on whether you display top/bottom pager at the same time. Further information about the FireCommandEvent usage can be found here.
  4. RadGrid with paging enabled behaves in the same way as the standard MS GridView control, i.e. the items on the active page only are available through the Items collection of the grid. If you would like to iterate through the entire set of data, consider traversing the records in the underlying source (DataTable or a custom collection) directly with your own custom code.
Best regards,
Stephen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Rama
Top achievements
Rank 1
Answers by
Rama
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or