• 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;
        }
  • 相关阅读:
    centos7查看系统版本,查看机器位数x86-64
    CentOS7下安装mysql5.6修改字符集为utf8并开放端口允许远程访问
    CentOS7下mysql5.6修改默认编码
    使用swagger作为restful api的doc文档生成
    在idea中maven项目jdk编译version总是跳到1.5
    国内maven镜像,快的飞起
    醒悟,珍惜时间,学会利用资源
    重定向Http status code 303 和 302
    jackson简单使用,对象转json,json转对象,json转list
    2017 年度码云新增项目排行榜 TOP 50,为它们打“call”
  • 原文地址:https://www.cnblogs.com/weiyuxinghuacun/p/1634735.html
Copyright © 2020-2023  润新知