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

RadGrid Paging

1 Answer 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yuri R
Top achievements
Rank 1
Yuri R asked on 03 May 2010, 04:07 PM
Hello,

I'm using Q1 2010

I have implemented a RadGrid as follows:

<telerik:RadAjaxPanel ID="RadAjaxPanel" runat="server">  
  <telerik:RadGrid ID="Grid1" runat="server" ShowStatusBar="True" AllowPaging="true" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" 
  
Skin="Black" OnItemDataBound="Grid1_ItemDataBound">  
                <MasterTableView Width="100%" ShowHeader="true" CommandItemDisplay="None" ShowFooter="true" DataKeyNames="itm_TableID" ClientDataKeyNames="itm_TableID" DataSourceID="SqlDataSource1" PageSize="10" 
AutoGenerateColumns="False" Dir="RTL" AllowSorting="true" TableLayout="Fixed" PagerStyle-AlwaysVisible="true">  
                    <Columns> 
                        <telerik:GridBoundColumn UniqueName="itm_TableID" DataField="itm_TableID" HeaderText="ID" ReadOnly="true" HeaderStyle-Width="2%" Display="false">  
                        </telerik:GridBoundColumn> 
                          
                        <telerik:GridTemplateColumn UniqueName="CategorySelect" ItemStyle-Width="3%">                              
                            <ItemTemplate> 
                                <asp:CheckBox id="chkCategorySelect" OnCheckedChanged="chkCategorySelect_Click" AutoPostBack="True" runat="server" CssClass="checkBox"></asp:CheckBox> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn> 
 
                        <telerik:GridBoundColumn UniqueName="itm_ID" DataField="itm_ID" HeaderText="" ReadOnly="true" HeaderStyle-Width="3%" ItemStyle-Width="3%" HeaderStyle-HorizontalAlign="Right">                              
                        </telerik:GridBoundColumn> 
      
                        <telerik:GridBoundColumn UniqueName="itm_VTR" DataField="itm_VTR" HeaderText="VTR" HeaderStyle-Width="3%" ItemStyle-Width="3%" HeaderStyle-HorizontalAlign="Right">  
                            <HeaderStyle Width="3%"></HeaderStyle> 
                        </telerik:GridBoundColumn> 
 
                        <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="" HeaderStyle-Width="15%" ItemStyle-Width="15%" FooterStyle-Width="15%" FooterStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Right">  
                            <FooterTemplate> 
                                <telerik:RadTextBox ID="txtTotalTime" Runat="server" Skin="Black" Label="" Width="120px" ReadOnly="true"> 
                                </telerik:RadTextBox> 
                           </FooterTemplate> 
                            <ItemTemplate> 
                                <asp:Label ID="lblRemarks" runat="server" Text='<%# Bind("itm_Remarks", "{0}") %>'></asp:Label> 
                            </ItemTemplate> 
                        </telerik:GridTemplateColumn>                                                                          
                    </Columns>    
                    <PagerTemplate> 
                      <div style="direction: rtl;">  
                        <asp:Panel ID="PagerPanel" Style="padding: 6px; line-height: 24px;" runat="server" Direction="RightToLeft">  
                          <asp:Button ID="btnAdd" runat="server" Width="100px" Text="" CssClass="" Enabled="true"  OnClick="btnAddToCategory_Click" /> 
                         
                           <asp:Panel runat="server" ID="NumericPagerPlaceHolder" Direction="RightToLeft"/>  
                         
                        </asp:Panel> 
                      </div> 
                    </PagerTemplate> 
                           
                    <PagerStyle Mode="NumericPages" Position="TopAndBottom" HorizontalAlign="Center" /> 
                </MasterTableView>                  
                <ClientSettings AllowRowsDragDrop="false" EnableRowHoverStyle="false"  EnablePostBackOnRowClick="false">                     
                    <Selecting AllowRowSelect="false" EnableDragToSelectRows="false" /> 
                    <Resizing AllowColumnResize="false" ClipCellContentOnResize="true" /> 
                      
                </ClientSettings> 
                <HeaderContextMenu EnableAutoScroll="True"></HeaderContextMenu> 
           </telerik:RadGrid> 
          
        </telerik:RadAjaxPanel>  
with this code behind:
 protected void Page_Load(object sender, EventArgs e)  
        {             
        }  
 
 DateTime totalTime = new DateTime();                  
 
        protected void Grid1_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                GridDataItem dataItem = (GridDataItem)e.Item;  
             
                totalTime = totalTime.AddSeconds(Double.Parse(dataItem["itm_VTR"].Text));  
                                 
            }  
            else if (e.Item is GridFooterItem && endTime < castLength)  
            {  
                GridFooterItem footer = (GridFooterItem)e.Item;  
                (footer["TemplateColumn"].FindControl("txtTotalTime"as RadTextBox).Text = totalTime.ToString("HH:mm:ss");  
            }  
        }  
 
        

My problem is with the calculation(see code behind in Grid1_ItemDataBound),  which are displayed in "txtTotalTime" textbox, without paging the calculations work fine. However with paging, each page of the grid behaves like an independent grid and on each page i get the calculations of items of the current page only and not for the entire grid. I need to see on each page of the grid the calculation of all items of the grid.

I would appreciate any help.

Best Regards
Yuri

1 Answer, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 05 May 2010, 02:19 PM
Hi Yuri,

Please, refer to the help article below which elaborates on how to show grand total in a column footer which calculates the sum for the data in the column cells in all available pages:
http://www.telerik.com/help/aspnet-ajax/grdtotalsingridfooters.html (paragraph 'Displaying totals for all grid pages')

I hope this helps.

Kind regards,
Pavlina
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
Yuri R
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or