日期:2014-05-20  浏览次数:20888 次

Extjs菜鸟求帮助.。。

<html>
  <head>
  <meta http-equiv="Content-Type" Content="text/html; charset=GB2312" />
  <link rel="stylesheet" type="text/css" href="../../ext-3.2.1/resources/css/ext-all.css"></link>
  <script src="../../ext-3.2.1/adapter/ext/ext-base.js"></script>
  <script src="../../ext-3.2.1/ext-all.js"></script>
  <script type="text/javascript" src="../../ext-3.2.1/src/locale/ext-lang-zh_CN.js"></script>

  <script>
  Ext.onReady(function(){

  var cm = new Ext.grid.ColumnModel([ //对列的描述
  { header: '编号',dateIndex:'id',sortable:true},
  { header: '姓名',dateIndex:'name'},
  { header: '描述',dateIndex:'descn'},
{ header: '时间',dateIndex:'birthday', renderer:Ext.util.Format.dateRenderer('Y-m-d')}
  ]); 


  var data=[//声明表格中的数据
  ['1','name1','descn1','1992-1-2 13:50:33'],
  ['2','name2','descn2','1996-2-3 08:52:11'],
  ['3','name3','descn3','1995-3-4 06:53:44'],
  ['4','name4','descn4','1994-4-5 03:54:13'],
  ['5','name5','descn5','1993-5-6 04:57:22']
  ];

  var store = new Ext.data.Store({
  proxy: new Ext.data.MemoryProxy(data),//表明数据是从内存中读取过来的
 // proxy: new Ext.data.ScriptTagProxy({url:'www.cstp.net.cn'}),//表明数据是从内存中读取过来的
  reader: new Ext.data.ArrayReader({},[//表明如何来读取这些数据,以数组方式进行读取,将数组中的数据与其列对应起来
  {name:'id'},
  {name:'name'},
  {name:'descn'},
  {name:'birthday',type: 'date' ,dateFromat:'Y-m-d H:i:s'}
  ])
// sortInfo:{field:"name",direction:"DESC" }
  });

  store.load();//加载数据
   
  var grid = new Ext.grid.GridPanel({
  autoHeight : true,
enableColumnMove:false,
enadbleColumnResize:false,
stripeRows:true, 
stripeRow:true,
loadMask:true,
renderTo: 'grid',//在指定的位置进行渲染 
store: store,
cm:cm,
viewConfig:{
forceFit: true
}
  });

}
   
);

  </script>
  </head>
   
  <body>
  <div id='grid'></div>

  </body>
</html>
我在表格中加入了时间但是内容就是显示不出来。还有就是排序问题加上排序了页面上那个排序点了没反应。

------解决方案--------------------
<script type="text/javascript">
function showUrl(value)
{
return ""+value+"";
}
Ext.onReady(function(){
var data=[ [1, 'EasyJWeb', 'EasyJF','www.easyjf.com'],
[2, 'jfox', 'huihoo','www.huihoo.org'],
[3, 'jdon', 'jdon','www.jdon.com'],
[4, 'springside', 'springside','www.springside.org.cn'] ];
var store=new Ext.data.SimpleStore({data:data,fields:["id","name","organization","homepage"]});
var colM=new Ext.grid.ColumnModel([{header:"项目名称",dataIndex:"name",sortable:true},
{header:"开发团队",dataIndex:"organization",sortable:true},
{header:"网址",dataIndex:"homepage",renderer:showUrl}]);
var grid = new Ext.grid.GridPanel({
renderTo:"hello",
title:"中国Java开源产品及团队",
height:200,
width:600,
cm:colM,
store:store,
autoExpandColumn:2
});
});
</script>