码迷,mamicode.com
首页 > 其他好文 > 详细

easyui的datagrid实例练习

时间:2015-04-22 22:02:57      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

一、html文件代码

技术分享
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4     <meta charset="UTF-8">
 5     <title>Basic DataGrid - jQuery EasyUI Demo</title>
 6     <link rel="stylesheet" type="text/css" href="easyui/themes/default/easyui.css">
 7     <link rel="stylesheet" type="text/css" href="easyui/themes/icon.css">
 8     <link rel="stylesheet" type="text/css" href="easyui/demo/demo.css">
 9     <script type="text/javascript" src="easyui/jquery.min.js"></script>
10     <script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
11     <script type="text/javascript" src="datagrid3.js"></script>
12 </head>
13 <body>
14     初中英语单词与短语大全
15     <table id="dgbox"></table>
16 </body>
17 </html>
View Code

二、js文件代码

技术分享
 1 $(function () {
 2     $(‘#dgbox‘).datagrid({
 3         width : 500,
 4         //url : ‘content.json‘,
 5         url : ‘datagrid3.php‘,
 6         title : ‘用户列表‘,
 7         iconCls : ‘icon-search‘,
 8         columns : [[
 9             {
10                 field : ‘ch‘,
11                 title : ‘汉语‘,
12             },
13             {
14                 field : ‘en‘,
15                 title : ‘英语‘,
16             },
17             {
18                 field : ‘fenlei2‘,
19                 title : ‘分类‘,
20             },
21         ]],
22         pagination : true,
23         pageSize : 15,
24         pageList : [5, 10, 15],
25         pageNumber : 1,
26         pagePosition : ‘bottom‘,
27     });
28     
29 });
View Code

三、php文件代码

 1 <?php
 2     //sleep(1);
 3     header(‘Content-Type:text/html; charset=utf-8‘);
 4     require ‘config.php‘;
 5     $page = $_POST[‘page‘];
 6     $pageSize = $_POST[‘rows‘];
 7     $first = $pageSize * ($page - 1);
 8     $biaoname="testeasyui_users";
 9     $biaoname="english";
10     $query = mysql_query("SELECT * FROM ".$biaoname." LIMIT $first,$pageSize") or die(‘SQL 错误!‘);
11     $json = ‘‘;
12     while (!!$row = mysql_fetch_array($query, MYSQL_ASSOC)) {
13         $json .= json_encode($row).‘,‘;
14     }
15     $total = mysql_num_rows(mysql_query("SELECT * FROM ".$biaoname));
16     $json = substr($json, 0, -1);
17     echo ‘{"total" : ‘.$total.‘, "rows" : [‘.$json.‘]}‘;
18     mysql_close();
19 ?>

 

easyui的datagrid实例练习

标签:

原文地址:http://www.cnblogs.com/qq2dfans/p/4448699.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!