Ext.onReady(function(){
var recordType = new Ext.data.Record.create([ 
{name : "number",type : "string"}, {name : "name",type : "string"}, {name : "author",type : "string"}, {name : "press",type : "string"}, {name : "price",type : "string"}, {name : "language",type : "string"}, {name : "lend",type : "string"} ]); var reader = new Ext.data.JsonReader(     {totalProperty : "num",  root : "arr",id : "number"},recordType); var proxy=new Ext.data.HttpProxy({url : 'http://127.0.0.1:8080/Extjs03/personInfoGridLoad.jsp'}); var ds = new Ext.data.Store( {proxy:proxy,reader:reader}); ds.load(); 
var sm = new Ext.grid.CheckboxSelectionModel(); var cm = new Ext.grid.ColumnModel( {     defaultSortable : true,      columns : [ 
    sm, 
    {header:'<center>编号</center>',dataIndex:'number',width:100}, 
{header:'<center>名称</center>',dataIndex:'name',width:200}, 
{header:'<center>作者</center>',dataIndex:'author',width:80}, 
{header:'<center>出版社</center>',dataIndex:'press',width:200}, 
{header:'<center>价格</center>',dataIndex:'price',width:50}, 
{header:'<center>语种</center>',dataIndex:'language',width:70}, 
{header:'<center>是否借出</center>',dataIndex:'lend',width:60} 

}); 
  var libraryInfoGrid = new Ext.grid.GridPanel({ 
  title:'图书信息',  
         store: ds, 
         cm: cm, 
         sm:sm, 
         renderTo:Ext.getBody(),
         width:800, 
         height:400, 
         tools:[{id:"save"},{id:"help",handler:function(){Ext.MessageBox.alert("工具栏按钮","工具栏上的关闭按钮时间被激发了")}}],         
         tbar:[{ 
            text:'新增图书', 
            tooltip:'新增图书信息', 
            iconCls:'add' 
        }, '-', { 
            text:'修改', 
            tooltip:'修改图书信息', 
            iconCls:'option' 
        },'-',{ 
            text:'删除', 
            tooltip:'删除图书信息', 
            iconCls:'remove' 
        }], 
         region:'center', 
         bbar: new Ext.PagingToolbar({ 
             pageSize: 10, 
             store: ds, 
             displayInfo: true, 
             displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条', 
             emptyMsg: "没有记录" 
         }) 
     }); });其中访问http://127.0.0.1:8080/Extjs03/personInfoGridLoad.jsp将得到<br/>
{"arr":[{"author":"张孝详","language":"中文","lend":"否","name":"数据库","number":"10","press":"武汉大学出版社","price":"23.00"},{"author":"Scott Bee","language":"英文","lend":"是","name":"thinking in java","number":"20","press":"abc","price":"108"}],"num":2} <br/>
为什么显示不了数据呢?

解决方案 »

  1.   

    顶。JSP忘了啊。你最好把jsp中的关键代码也贴上了。
      

  2.   

    json中加上的{success:true,"arr":[{"author"。
      

  3.   

    json="{arr:[{author:'张1221孝详',language:'中文',lend:'否',name:'数据库',number:'10',press:'武汉大学出版社',price:'23.00'},{author:'Scott Bee',language:'英文',lend:'是',name:'thinking in java',number:'20',press:'abc',price:'108'}],num:3}";
    response.getWriter().print(json);
      

  4.   

    我是初学者,研究Extjs从后台读取数据绑定到Extjs的grid中,能不能给个具体实例啊,谢了啊
      

  5.   

    ’http://127.0.0.1:8080/Extjs03/personInfoGridLoad.jsp‘这个里面的代码该怎么写啊?
      

  6.   

    我是初学者 能不能给我一个 extjs连接数据库的代码