当前位置: 首页 > 工具软件 > PHP DataGrid > 使用案例 >

今天无事,就试试一个php datagrid

公孙国兴
2023-12-01
先贴代码:

<?php      
include ("phpmydatagrid.class.php");
$objGrid = new datagrid;

$objGrid->closeTags(true);
$objGrid->friendlyHTML();
$objGrid->methodForm("get");
//连接数据库
$objGrid->conectadb("127.0.0.1", "root", "123456", "eesinasale");//加密字符串
$objGrid->salt("Myc0defor5tr0ng3r-Pro3EctiOn");
$objGrid->language("en");
//最后一列显示的功能键,从左向右功能为“新增键”、“编辑键”、“删除键”、“浏览键”。
$objGrid->buttons(true,true,true,true);
//修改数值时产生的Form名称
$objGrid->form('employee', true);
//可检索列名
$objGrid->searchby("name,lastname");
//需要读取的表
$objGrid->tabla("e_m_avanum");
//索引值用于修改数据
$objGrid->keyfield("uid");
//分页显示行数
$objGrid->datarows(20);
//默认排序方式
$objGrid->orderby("uid", "ASC");
//显示列设置,相关设置可参考phpmydatagrid.class.php
$objGrid->FormatColumn("uid", "ID Employee", 5, 5, 1, "50", "center");
$objGrid->FormatColumn("Ehuahao", "Name", 30, 30, 0, "150", "left");
$objGrid->FormatColumn("Efax", "Last name", 30, 30, 0, "150", "left");
$objGrid->FormatColumn("fenjihao", "Age", 5, 5, 0, "50", "right");//自定义日期格式
$objGrid->FormatColumn("PcPhoneCity", "Afiliation Date", 10, 10, 0, "100", "center", "date:dmy:/");//编辑时可以自定义为<Select>模式
$objGrid->FormatColumn("status", "Status", 5, 5, 0, "60", "left", "select:1_Single:2_Married:3_Divorced");
//编辑时可以自定义为<CheckBox>模式
$objGrid->FormatColumn("CreateTime", "Active", 2, 2, 0,"50", "center", "check:No:Yes");//自定义货币显示形式
$objGrid->FormatColumn("ChangTime", "Salary", 10, 10, 0, "90", "right", "money:€");//将数据以柱状图显示
$objGrid->FormatColumn("DealID", "Work days", 5, 2, 0, "50", "right", "chart:percent:val:31");
$objGrid->checkable();
$objGrid->setHeader();
$objGrid->ajax('silent');
echo '<html>
<head><title>PHPDataGrid</title></head>
<body><div align="center"><br />';
//生成DataGrid
$objGrid->grid();
echo '</div></body></html>';//关闭数据库连接
$objGrid->desconectar();
?>


在网上下载一个phpmydatagrid就可以使用了,很简单的datagrid ,但是速度还可以,毕竟小!!不过效果一般,和YUI的效果差距有点大,列不能左右拉动!下次去试试YUI的datagrid
 类似资料: