KLL 2012-08-29 10:01 采纳率: 0%
浏览 207
已采纳

ext grid显示json数据

刚开始学ext,在网上找了个例子就是数据都不出来
<%--Default.aspx--%>
<html xmlns="http://www.w3.org/1999/xhtml" >
<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(){

            var proxy=new Ext.data.HttpProxy(    
                {
                    url:'Default2.aspx'
                }
            );
            //定义reader
            var reader=new Ext.data.JsonReader(
                {
                },
                [
                    {name: 'appeId'},
                    {name: 'survId'},
                    {name: 'location'}, 
                    {name: 'surveyDate'},
                    {name: 'surveyTime'},
                    {name: 'inputUserId'}           
                ]
            )
            //构建Store   
            var store=new Ext.data.Store(    {
              proxy:proxy,
              reader:reader
            });
            
            //载入
            store.load();

            // create the grid
            var grid = new Ext.grid.GridPanel({
                store: store,
                columns: [
                    {header: "appeId", width: 60, dataIndex: 'appeId', sortable: true},
                    {header: "survId", width: 60, dataIndex: 'survId', sortable: true},
                    {header: "location", width: 60, dataIndex: 'location', sortable: true},
                    {header: "surveyDate", width: 100, dataIndex: 'surveyDate', sortable: true},
                    {header: "surveyTime", width: 100, dataIndex: 'surveyTime', sortable: true},
                    {header: "inputUserId", width:80, dataIndex: 'inputUserId', sortable: true}
                ],
                renderTo:'example-grid',
                width:540,
                height:200
            });
        });
        
    </script>
    
</head>
<body>
    <form id="form1" runat="server">
    <div id="example-grid">
    
    </div>
    </form>
</body>
</html>
<%--Default2.aspx--%>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%=strJson %>
<%--Default2.aspx.cs--%>
public string strJson;
    protected void Page_Load(object sender, EventArgs e)
    {
        strJson = @"
            [
                {'appeId':'1','survId':'1','location':'','surveyDate':'2008-03-14','surveyTime':'12:19:47','inputUserId':'1','inputTime':'2008-03-14 12:21:51','modifyTime':'0000-00-00 00:00:00'},
                {'appeId':'2','survId':'32','location':'','surveyDate':'2008-03-14','surveyTime':'22:43:09','inputUserId':'32','inputTime':'2008-03-14 22:43:37','modifyTime':'0000-00-00 00:00:00'},
                {'appeId':'3','survId':'32','location':'','surveyDate':'2008-03-15','surveyTime':'07:59:33','inputUserId':'32','inputTime':'2008-03-15 08:00:44','modifyTime':'0000-00-00 00:00:00'},
                {'appeId':'4','survId':'1','location':'','surveyDate':'2008-03-15','surveyTime':'10:45:42','inputUserId':'1','inputTime':'2008-03-15 10:46:04','modifyTime':'0000-00-00 00:00:00'},
                {'appeId':'5','survId':'32','location':'','surveyDate':'2008-03-16','surveyTime':'08:04:49','inputUserId':'32','inputTime':'2008-03-16 08:05:26','modifyTime':'0000-00-00 00:00:00'},
                {'appeId':'6','survId':'32','location':'','surveyDate':'2008-03-20','surveyTime':'20:19:01','inputUserId':'32','inputTime':'2008-03-20 20:19:32','modifyTime':'0000-00-00 00:00:00'}
            ]";
    }
  • 写回答

3条回答 默认 最新

  • works001 2012-08-29 10:16
    关注

    貌似你用的是4版本
    而你代码是2或3版本的写法
    建议看看4版本的官方例子

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据