一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jqGrid 导出excel表格代码(php+jqgrid实例)

时间:2022-06-24 18:32:55 编辑:袖梨 来源:一聚教程网

require_once '../../../tabs.php';
?>

 代码如下 复制代码

http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd">

 
    jqgrid php demo
   
    css教程" media="screen" href="../../../themes/redmond/jquery-ui-1.7.1.custom.css" />
   
   
   
   
   
   
   
   
 
 
     


         
     

     

     
  

php代码

require_once '../../../jq-config.php';
// include the jqgrid class
require_once abspath."php/jqgrid.php";
// include the driver class
require_once abspath."php/jqgridpdo.php";
// connection to the server
$conn = new pdo(db_dsn,db_user,db_password);
// tell the db that we use utf-8
$conn->query("set names utf8");

// create the jqgrid instance
$grid = new jqgridrender($conn);
// write the sql query
$grid->selectcommand = 'select orderid, orderdate, customerid, freight, shipname from longorders';
// set the ouput format to json
$grid->datatype = 'json';
// let the grid create the model
$grid->setcolmodel();
// set the url from where we obtain the data
$grid->seturl('grid.php');
$grid->optimizesearch = true;
// set some grid options
$grid->setgridoptions(array("rownum"=>100,"sortname"=>"orderid","height"=>150));
// change some property of the field(s)
$grid->setcolproperty("orderdate", array(
    "formatter"=>"date",
    "formatoptions"=>array("srcformat"=>"y-m-d h:i:s","newformat"=>"m/d/y"),
    "search"=>false
    )
);
// enable toolbar searching
$grid->toolbarfilter = true;
$grid->setfilteroptions(array("stringresult"=>true));
// enjoy
$grid->rendergrid('#grid','#pager',true, null, null, true,true);
$conn = null;
?>

 

热门栏目