kll329582600
KLL
2012-08-29 17:17
浏览 256
已采纳

ext4 grid显示问题

<head runat="server">
    <title>Ext-Example</title>
    <link rel="Stylesheet" type="text/css" href="ext-4.0-pr5/resources/css/ext-all.css" />
    <script type="text/javascript" src="ext-4.0-pr5/bootstrap.js"></script>
    
    <script type="text/javascript">   
       
    Ext.onReady(function(){
        Ext.define('MyData',{
            extend:'Ext.data.Model',
            fields:[
                {name:'UserName',mapping:'UserName'},
                'Sex',
                'Age',
                'XueHao',
                'BanJi'
            ]
        });
        
        var store=Ext.create('Ext.data.Store',{
            model:'MyData',
            proxy:{
                type:'ajax',
                url:'Default.aspx',
                reader:{
                    type:'json',
                    root:'items'
                }
            },
            autoLoad:true
        });
        
        var grid=Ext.create('Ext.grid.GridPanel',{
            store:store,
            columns:[
                {text:"姓名",width:120,dataIndex:'UserName',sortable:true},
                {text:"性别",flex:1,dataIndex:'Sex',sortable:false},
                {text:"年龄",width:100,dataIndex:'Age',sortable:true},
                {text:"学号",width:100,dataIndex:'XueHao',sortable:true},
                {text:"班级",width:100,dataIndex:'BanJi',sortable:true}
            ],
            height:400,
            width:480,
            x:20,
            y:40,
            title:'ExtJS4 Grid示例',
            renderTo:'demo',
            viewConfig:{
                stripeRows:true
            }
        });
        
    });

        
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div id="demo">
    
    </div>
    </form>
</body>
</html>

 什么也不显示,var grid=Ext.create('Ext.grid.Panel'改成GridPanel就出现个表一直在呢loading没有数据

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

7条回答 默认 最新

  • iteye_5246
    iteye_5246 2012-08-29 17:56
    已采纳

    测试这个数据。
    {

    total:5,

    result:[
    {

    id:"1",

    UserName:"李彦宏",

    Sex:"男",

    Age:"20"

    },{

    id:"2",

    UserName:"langsin2",

    Sex:"1",

    Age:"21"

    },{

    id:"3",

    UserName:"langsin3",

    Sex:"0",

    Age:"22"

    },{

    id:"4",

    UserName:"langsin4",

    Sex:"1",

    Age:"23"

    },{

    id:"5",

    UserName:"langsin5",

    Sex:"0",

    Age:"24"

    }]

    }

    点赞 评论
  • works001
    works001 2012-08-29 17:23

    ext4官方api中:
    [code="java"]Ext.create('Ext.grid.Panel', {
    title: 'Simpsons',
    store: Ext.data.StoreManager.lookup('simpsonsStore'),
    columns: [
    { header: 'Name', dataIndex: 'name' },
    { header: 'Email', dataIndex: 'email', flex: 1 },
    { header: 'Phone', dataIndex: 'phone' }
    ],
    height: 200,
    width: 400,
    renderTo: Ext.getBody()
    });[/code]
    Ext.create('Ext.grid.Panel' 这个哦

    点赞 评论
  • iteye_5246
    iteye_5246 2012-08-29 17:26

    后台返回json有问题

    点赞 评论
  • FangXingXing007
    FangXingXing007 2012-08-29 17:27

    [quote]columns:[

    {text:"姓名",width:120,dataIndex:'UserName',sortable:true},

    {text:"性别",flex:1,dataIndex:'Sex',sortable:false},

    {text:"年龄",width:100,dataIndex:'Age',sortable:true},

    {text:"学号",width:100,dataIndex:'XueHao',sortable:true},

    {text:"班级",width:100,dataIndex:'BanJi',sortable:true}

    ][/quote]
    里面的text在Ext中已经成了header,text属性是不起作用的

    点赞 评论
  • iteye_5246
    iteye_5246 2012-08-29 17:45

    [
    ["UserName":"李彦宏","Sex":"男","Age":"25","XueHao":"1","BanJi":"一班"],
    ["UserName":"马云","Sex":"男","Age":"31","XueHao":"2","BanJi":"二班"]
    ]

    点赞 评论
  • iteye_5246
    iteye_5246 2012-08-29 17:45

    测试我发送的json试一下

    点赞 评论
  • iteye_5246
    iteye_5246 2012-08-29 18:00

    错了,没看到

    root:'items'

    {

    total:5,

    items:[
    {

    id:"1",

    UserName:"李彦宏",

    Sex:"男",

    Age:"20"

    },{

    id:"2",

    UserName:"langsin2",

    Sex:"1",

    Age:"21"

    },{

    id:"3",

    UserName:"langsin3",

    Sex:"0",

    Age:"22"

    },{

    id:"4",

    UserName:"langsin4",

    Sex:"1",

    Age:"23"

    },{

    id:"5",

    UserName:"langsin5",

    Sex:"0",

    Age:"24"

    }]

    }

    点赞 评论

相关推荐