zoukankan      html  css  js  c++  java
  • ExtJS中的Grid分页

    1.建立页面:

    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=gbk">
            <title>03.grid</title>

    //引入必要文件
            <link rel="stylesheet" type="text/css" href="http://www.cnblogs.com/resources/css/ext-all.css" />
            <script type="text/javascript" src="http://www.cnblogs.com/adapter/ext/ext-base.js"></script>
            <script type="text/javascript" src="http://www.cnblogs.com/ext-all.js"></script>
            <script type="text/javascript">
    Ext.onReady(function(){

    //定义表头   

    var cm = new Ext.grid.ColumnModel([
            {header:'编号',dataIndex:'id'},
            {header:'名称',dataIndex:'name'},
            {header:'描述',dataIndex:'descn'}
        ]);

    //定义数据   

    var store = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url:'Pager.php'}),
            reader: new Ext.data.JsonReader({
                totalProperty: 'totalProperty',
                root: 'root'
            }, [
                {name: 'id'},
                {name: 'name'},
                {name: 'descn'}
            ])
        });

    //定义表格   

    var grid = new Ext.grid.GridPanel({
            renderTo: 'grid',
            autoHeight: true,
            store: store,
            cm: cm,
            bbar: new Ext.PagingToolbar({
                pageSize: 10,
                store: store,
                displayInfo: true,
                displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
                emptyMsg: "没有记录"
            })
        });
        store.load({params:{start:0,limit:10}}); //初始化数据显示

    });
            </script>
        </head>
        <body>
            <script type="text/javascript" src="../examples.js"></script>
            <div id="grid" style="height:265px;"></div>
        </body>
    </html>

    2.PHP:

    <?php

    //返回Json格式数据,可以从数据库中查询获得,分页时传人两个参数:start和limit,可以使用$_POST[‘start’]和$_POST[‘limit’]获得,此略

    $s=’{totalProperty:100,root:[{id:0,name:’name0’,descn:’descn0’},{id:1,name:’name1’,descn:’descn1’},{id:2,name:’name2’,descn:’descn2’}]}’;

    echo $s;

    ?>

  • 相关阅读:
    画图工具Graphviz安装配置
    转:完善eclipse+pdt作php开发中的代码提示能力
    转:SVN 出现This client is too old to work with working copy...错误
    Codeforces Round #260 (Div. 2)C. Boredom(dp)
    three.js 源代码凝视(十四)Math/Sphere.js
    android项目中刷新activity界面
    中科燕园GIS外包---地铁GIS项目
    华为HCNA教程(笔记)
    HapiJS开发手冊
    《Java并发编程实战》第十四章 构建自己定义的同步工具 读书笔记
  • 原文地址:https://www.cnblogs.com/GarfieldTom/p/1511775.html
Copyright © 2011-2022 走看看