您的位置:首页 > 数据库

ext之实现列表(从后台数据库读取数据)

2013-08-19 22:28 393 查看
php_Customer_list.php页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >

<html xmlns="http://www.w3.org/1999/xhtml" >  

<head>  

<link rel="stylesheet" type="text/css" href="ext/resources/css/ext-all.css" />  

<script type="text/javascript" src="ext/adapter/ext/ext-base.js"></script>  

<script type="text/javascript" src="ext/ext-all.js"></script>    

<script type="text/javascript">  

  Ext.onReady( function() {   

   var dd = new Ext.data.JsonStore( {   
 url:'GetData_Customer.php',
 root:"rows",   

          totalProperty:"total",                   

          fields : ["code","name","AbbName"]   

       });   

      // 从数组里面装载数据   

      dd.load();   

      var grid = new Ext.grid.GridPanel( {   

        store :dd,   

        columns : [ {   

          id : "CC", // 内部的标识   

          header : "客户编号", // 显示的标题   

          width : 60, // 宽度   

          sortable : true, // 是否可以排序   

          dataIndex : "code" // 对应数据集的字段   

        },{   

          id :"CN",   

          header :"名称",   

          width :160,   

          //sortable :true,   

          dataIndex :"name"   

        }, {   

          id :"CA",   

          header :"客户简称",   

          width :160,   

          //sortable :true,   

          dataIndex :"AbbName"  

        }],

        autoExpandColumn :"CN", // 这个列将默认占用所有的可用的列宽   

        height :350, // 高度   

        width :600, // 宽度   

        title :"客户人员信息表格" // 表格的标题   

      });   

  

      grid.render('grid-example'); // 生成到这个id标签里面   

    });   

</script>  

</head>  

<body>  

<div id="grid-example"></div>  

</body>  

</html>  

GetData_Customer.php页面

<?php

$DontCheckLogin = true;

include_once("tglobal.lib");

$i=0;

$stmt = new TSQLStmt();

$stmt->Table("Customer","m");

$stmt->Select("m","cCusCode");

$stmt->Select("m","cCusName");

$stmt->Select("m","cCusAbbName");

$sql = $stmt->SQLGen();

$rs = $gblDB->Query($sql);

if($rs)

{
while($rs->fetchRecord())
{
//echo "cCusCode:".$rs->getFieldValueByName("cCusCode")."<BR>";
//echo "cCusName:".$rs->getFieldValueByName("cCusName")."<BR>";
//echo "cCusAbbName:".$rs->getFieldValueByName("cCusAbbName")."<BR>";
$code = $rs->getFieldValueByName("cCusCode");
$name = $rs->getFieldValueByName("cCusName");
$AbbName = $rs->getFieldValueByName("cCusAbbName");
$array[$i]=array('code'=>$code,'name'=>$name,'AbbName'=>$AbbName);
$i=$i+1;
}
$rs->close();

}

$json="";

$json.="{";

$json.="'total':";

$json.="".$i.",";

$json.="'rows':";

$json.="[";

for($j=0;$j<=$i-1;$j++)

{

 $json.="".json_encode($array[$j])."";

 $json.=",";

}

$json.="]";

$json.="}";

//$json=json_encode($data);

//$json_data="{"."total".":".$i.","."rows".":".$json."}";

//$json_data="{'rows':$json}";
echo $json;

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐