zoukankan      html  css  js  c++  java
  • RadRadGrid custom paging(用户自定义分页)

    感觉 RadGrid 用户自定义分页和asp.net pager很相似

    需要注意的是1.启用AllowCustomPaging=true;

                     2.设置VirtualItemCount=表的总记录数

    详细代码如下;

    ==============================================

    aspx

    ----------------------------------------------------------------------

    代码
    <div class="div1">
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" GridLines="None" AllowMultiRowSelection="True" OnNeedDataSource="RadGrid1_NeedDataSource" AllowCustomPaging="True">
                
    <HeaderContextMenu EnableTheming="True">
                    
    <CollapseAnimation Duration="200" Type="OutQuint" />
                
    </HeaderContextMenu>
                
    <MasterTableView AutoGenerateColumns="False" ClientDataKeyNames="ZJID" CommandItemDisplay="Top" NoMasterRecordsText="没有记录显示">
                                     
    <Columns>
                        
    <telerik:GridClientSelectColumn Reorderable="False" UniqueName="ClientSelectColumn" >
                        
    <ItemStyle HorizontalAlign="Center" />
                            
    <HeaderStyle HorizontalAlign="Center" Width="40px" />
    </telerik:GridClientSelectColumn>
                        
    <telerik:GridBoundColumn DataField="ID" DataType="System.Int32" HeaderText="序号"
                            ReadOnly
    ="True" SortExpression="ID" UniqueName="ID">
                        
    </telerik:GridBoundColumn>
                        
    <telerik:GridBoundColumn DataField="XM" HeaderText="姓名" SortExpression="XM"
                            UniqueName
    ="XM">
                        
    </telerik:GridBoundColumn>
                                       
    </Columns>
                             
    </MasterTableView>
                 
    <SortingSettings SortedAscToolTip="正序" SortedDescToolTip="倒序" SortToolTip="单击排序" />
               
    <ClientSettings EnableRowHoverStyle=True>
                    
    <Selecting AllowRowSelect="True" />
                    
    <ClientEvents OnRowDeselected="rowdeSelected" OnRowSelected="rowSelected" ></ClientEvents>
                
    </ClientSettings>            

    <ExportSettings ExportOnlyData="True" IgnorePaging="True" OpenInNewWindow="True"></ExportSettings>
                
    <FilterMenu EnableTheming="True">
                    
    <CollapseAnimation Duration="200" Type="OutQuint" />
                
    </FilterMenu>
        
    <PagerStyle Mode="Slider" />
            
    </telerik:RadGrid>
        
    </div>

    ------------------------------

    cs代码

    代码
    protected void Page_Load(object sender, EventArgs e)
        {
            SqlHelper helper 
    = new SqlHelper();

            
    string str = "select count(*) from Table1";
            RadGrid1.VirtualItemCount 
    = (int)helper.ExecuteScalar(str);

        }
     
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            
    int startRowIndex = RadGrid1.CurrentPageIndex * RadGrid1.PageSize;
            SqlHelper helper 
    = new SqlHelper();
            
    //sql2005   
            string str = "select * from (select * , row_number() over( order by ID) as n from Table1) as t where n between " + startRowIndex + " and  " + (startRowIndex + RadGrid1.PageSize) + "";
                    DataSet dt 
    = helper.ExecuteDataSet(str);

            RadGrid1.DataSource 
    = dt;
        }
  • 相关阅读:
    【CS Round #46 (Div. 1.5) B】Letters Deque
    【CS Round #46 (Div. 1.5) A】Letters Deque
    【Codeforces Round #432 (Div. 2) A】 Arpa and a research in Mexican wave
    【Codeforces Round #432 (Div. 2) B】Arpa and an exam about geometry
    【Codeforces Round #432 (Div. 1) A】 Five Dimensional Points
    【2017 Multi-University Training Contest
    Managing remote devices
    防止表单重复提交的解决方案整理
    防止表单重复提交的解决方案整理
    日期格式化函数
  • 原文地址:https://www.cnblogs.com/weiyuxinghuacun/p/1634735.html
Copyright © 2011-2022 走看看