---
layout: post
title: HiGridpro快速安装向导
description: HiGridpro快速安装向导
keywords: higrid
author: admin
date: 2012-10-08 15:49
category: 嗨网文档
tags: higridpro
---




## 系统需求

1. PHP 5.1以上
1. PDO (MySQL or PostgreSQL) 例子为mysql

## 下载安装

### 目录结构为:

```
│ example.php //php文件例子
│ readme.txt
│ higridsql.sql //示例数据库
├─example //例子文件夹
│ config.php //数据库设置文件
├─higrid
│ │ HiGrid.php //higrid 主程序
│ │
│ └─scopbin //加密文件
│ 911006.php
├─js //js文件
└─themes //CSS样式文件
```

### 安装

1. 将下载的higrid.版本代码.rar解压缩
1. 新建数据库,将higridsql.sql导入数据库
1. 打开config.php设置数据库参数
1. 将解压缩后的全部文件上传到服务器,任意目录都可
1. 浏览器中打开example.php查看效果
1. 增加其他表格只需模仿example文件夹中的php文件修改相应参数即可

##注意事项

higrid展示jqgrid需要js和Css进行控制,因此一个显示页面的组成应该是这样的:

```









即:example下的文件如chanzhi.php


```

example.php就包含以上代码,只是使用参数ex=?来引用例子。
若您增加的例子如yourgrid.php可以采用`path/example.php?ex=yourgrid.php`;

以上js和Css采用jqgrid官方的推荐写法,即:

```html









```


## 参数配置说明

```php
defined('HIPATH') || define('HIPATH', dirname(__FILE__).'/');//本语句定义本文件的绝对路径
require_once(HIPATH.'config.php');//config.php保存着数据库连接设置,修改本目录下config.php相关参数

$connhigrid = new PDO(DB_DSN,DB_USER,DB_PASSWORD);//创建一个新的链接
$connhigrid->query("SET NAMES utf8");//设置数据库字符集

$grid = new hgGridRender($connhigrid);//实例化一个对象
//嗨网higrid:执行SQL查询,可自定义SQL语句
$grid->higridSC = 'SELECT * FROM higrid_letter';
$grid->setUserDate('Y-m-d');//自定义年月日显示方式
//也可以$grid->setUserDate('m/d/Y');

$grid->datearray = array('receiveddate','donedate');//'receiveddate'和'donedate'是这个表的两个日期字段

$grid->table = 'higrid_letter';//本数据库的表名称

//自动CRUD操作的key,唯一
$grid->setPrimaryKeyId('letterid');

$grid->dataType = 'json';
$grid->setColModel();


//嗨网higrid:隐藏部分列。默认所有列显示
$grid->higridsCP("letterid", array("hidden"=>true));
$grid->higridsCP("doneby", array("hidden"=>true));
$grid->higridsCP("donedate", array("hidden"=>true));

$grid->higridsCP('letterdate',
array("label"=>"收发文日期","width"=>"70",'align'=>'center',"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d", "newformat"=>"Y-m-d"),
"editoptions"=>array(
"defaultValue"=>date("Y-m-d"),
"dataInit"=>
"js:function(elm){setTimeout(function(){
jQuery(elm).datepicker({dateFormat:'yy-mm-dd'});
jQuery('.ui-datepicker').css({'font-size':'75%'});
},200);}")
));

//设置每个字段名称,宽度,类型,是否必填?默认字符,筛选过滤选项等等
$grid->higridsCP("lettercontent", array("label"=>"函件内容",'width'=>250,"edittype"=>"textarea", "editrules"=>array("rows"=>10, "cols"=> 100,'width'=>400,"required"=>true)));
$grid->higridsCP('fromunit', array("width"=>"60",'align'=>'center', 'label'=>'发文单位', "formoptions"=>array("label"=>"发文单位", "elmsuffix"=>"按下拉菜单选择")));
$grid->higridsCP('tounit', array("width"=>"60",'align'=>'center', 'label'=>'收文单位',));
$grid->higridsCP('originid', array("width"=>"80",'label'=>'编号',));
$grid->higridsCP('donedate', array("editoptions"=>array("defaultValue"=>date("Y-m-d"))));
$grid->setSelect("fromunit", array("部门一"=>"部门一","部门二"=>"部门二", "IBM"=>"IBM","google国内"=>"google国内","其他"=>"其他"), false, true, true, array(""=>"默认公司"));
$grid->setSelect("tounit", array("部门一"=>"部门一","部门二"=>"部门二", "IBM"=>"IBM","google国内"=>"google国内","其他"=>"其他"), false, true, true, array(""=>"默认公司"));

//嗨网higrid:post数据处理文件,一般设置本脚本文件路径
$grid->setUrl('./example/letter.php');
//嗨网higrid:表格列属性设置
$grid->higridsGO(array(
"rownumbers"=>true,//是否显示行号,默认false
"caption"=>"工作台账",//自定义标题
"hoverrows"=>true,//鼠标滑动是否变色
"altRows"=>true,//是否显示斑马表格
"rowNum"=>20,//默认行数
"height"=>300,//表格高度
"rowList"=>array(20,50,100,200),//每页多少数据
"sortname"=>"letterdate",//排序的字段名称
"sortable"=>true,//是否启动排序
'sortorder'=>'desc'));//指定排序方式
//嗨网higrid:表格列属性设置结束

$grid->navigator = true;//导航是否显示

//页面编辑设置true可用;false不显示、不可用
$grid->higridsNO('navigator', array("excel"=>true,"add"=>true,"edit"=>false,"del"=>false,"view"=>true, "refresh"=>true,"search"=>true,"pdf"=>false));

//增加数据对话框个性化
$grid->higridsNO('add',array("width"=>500,"height"=>300,"dataheight"=>"auto",
"closeAfterAdd"=>true,"reloadAfterSubmit"=>true));//添加数据完后关闭对话框
//编辑数据对话框个性化
$grid->higridsNO('edit',array("width"=>500,"height"=>300,"dataheight"=>"auto",
"closeAfterEdit"=>true,"reloadAfterSubmit"=>true,"editCaption"=>"编辑数据","bSubmit"=>"更新"));

//最终表格的table div id,pager div id
//本页的html代码

$grid->higridOP('#cd_lettergrid','#cd_letterpager',true, null, null, true,true);
$connhigrid = null;//关闭连接

```