zoukankan      html  css  js  c++  java
  • easy ui datagrid 数据分页

    参照easyui官方网站提供的demo写了个datagrid数据分页的demo,

    具体参数我就不一一罗列了,详细见官方网站,

    这里只介绍一下具体的注意事项和常乃用到的几项,

     1  $('#test').datagrid({
     2                 iconCls: 'icon-save',
     3                 nowrap: false,
     4                 striped: true,
     5                 url: 'UserHandler.ashx?action=List',
     6                 title: 'DataGird',
     7                 loadMsg: "正在加载,请稍等...",
     8                  350,
     9                 height: 300,
    10                 singleSelect: true,
    11                 columns: [[
    12                     { field: 'UserName', title: '编号',  80 },
    13                     { field: 'Password', title: '姓名',  100 },
    14                 ]],
    15                
    16                 pagination: true,
    17                 rownumbers: true
    18             });

    具体的列,在代码中11到14行,其中UserName和Password对应json字符串中的键,
    注意:这里“pagination:true”必须显式加上,默认为false,

    再来看服务器端:

     1  int pageSize = 10;//通过这个获取得到pageSize
     2             int pageNum = 0;//通过这个获取得到pageNum
     3 
     4             if (Request["page"] != null)
     5             {
     6                 int.TryParse(Request["page"], out pageNum);
     7             }
     8 
     9             if (Request["rows"] != null)
    10             {
    11                 int.TryParse(Request["rows"], out pageSize);
    12             }
    13 
    14             string resultStr = "";
    15            
    16             resultStr += "{"total":" + lsFileType.Count + ","rows":[";
    17             for (int i = (pageNum - 1) * pageSize; i < pageSize; i++)
    18             {
    19                 resultStr += "{";
    20                 resultStr += string.Format(""UserName": "{0}", "Password": "{1}"", lsFileType[i].UserName, lsFileType[i].Password);
    21                 resultStr += "},";
    22             }
    23             resultStr = resultStr.Substring(0, resultStr.Length - 1);
    24             resultStr += "]}";

    需要注意的是:total和rows需要加上引号,开始我写成这样,
    resultStr += "{total:" + lsFileType.Count + ",rows:[";

    一直不显示数据。

    demo下载

  • 相关阅读:
    3、生成证书请求文件
    2、申请苹果App ID
    登录iOS Dev Center
    SQL Server 合并行
    asp 月末 月初
    linux
    ASP数组全集,多维数组和一维数组[转]
    oracle 秒
    oracle 存储过程 包 【转】
    linux
  • 原文地址:https://www.cnblogs.com/langhua/p/3140179.html
Copyright © 2011-2022 走看看