申倩倩 2009-07-03 12:03
浏览 538
已采纳

Ext.grid.GridPanel不显示数据怎么解决?

Ext.onReady(function() {

        var ds = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({ url: "GetQuestionList.aspx", method: 'GET' }),
            reader: new Ext.data.JsonReader(
                { root: 'data', totalProperty: 'totalCount' },
                [{ name: 'title', mapping: 'title' }, { name: 'type', mapping: 'type' }, { name: 'ct', mapping: 'ct' }, { name: 'state', mapping: 'state'}]
            )
        });

        var pagingBar = new Ext.PagingToolbar({
            pageSize: 5,
            store: ds,
            displayInfo: true,
            displayMsg: 'Displaying topics {0} - {1} of {2}',
            emptyMsg: "No topics to display"
        });

        var gv = new Ext.grid.GridPanel({
            title: '问题列表',
            el: 'divGvList',
            width: 800,
            height: 500,
            autoScroll: true,
            loadMask: { msg: '正在加载数据,请稍侯……' },
            store: ds,
            columns: [
                new Ext.grid.RowNumberer(),
                { header: '标题', dataIndex: 'title', sortable: true },
                { header: '分类', dataIndex: 'type', sortable: true },
                { header: '时间', dataIndex: 'ct', sortable: true, renderer: Ext.util.Format.dateRenderer('Y.m.d') },
                { header: '回复状态', dataIndex: 'state', sortable: true }
            ],
            bbar: pagingBar
        });
        gv.render();
        ds.load({ params: { start: 0, limit: 5} });
    });

这个GetQuestionList.aspx页面我单独用在ie地址栏输入GetQuestionList.aspx?start=0&limit=5,页面输出如下数据
{ 'data': [
{ 'title': '0_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '1_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '2_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '3_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '4_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '5_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '6_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '7_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '8_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true },
{ 'title': '9_标题', 'type': '分类', 'ct': '2009-7-3 11:49:58', 'state': true }
],
'totalCount': 10
}
不知道为什么就是显示不了数据,请大家帮忙看看到底问题出在哪了?
[b]问题补充:[/b]
我试了,还是不行
[b]问题补充:[/b]
郁闷,还是不行,不知道怎么回事
现在我加了alert(ds.getCount());,弹出的提示是0
是不是表示数据集中没有数据?
[b]问题补充:[/b]
都不是你们说的这些问题,我调试看了,可能是异步请求的问题
ds.load({
params: { start: 0, limit: 5 },
callback: function(r, options, success) {
alert(r.length);
if (success) {
alert(r.length);
} else { alert("加载数据失败,无对应数据或者系统出现异常!");}
}
});
我这样执行后,r.length总是0, success的值为false
有没有人知道是怎么回事
[b]问题补充:[/b]
问题解决了,GetQuestionList.aspx页面代码Response.Write(jsonStr);执行后还要加上 Response.Flush(); Response.Close();这两句代码,数据才能发送到客户端,那个回调函数success的值为true了,总算搞定了,不过还是要感谢各位帮忙!

  • 写回答

11条回答 默认 最新

  • zhoujuan520 2009-07-03 13:15
    关注

    [code="js"]//不一定所有对象都要分开写,有必要的才分开写.能不分开就不要分开.
    //要渲染到什么地方.最好在组件代码里面renderTo来渲染.
    Ext.onReady(function() {
    var ds = new Ext.data.Store({
    url: "GetQuestionList.aspx",//能简写的地方就简写:)
    reader: new Ext.data.JsonReader({
    root: 'data',
    totalProperty: 'totalCount'
    },
    [{
    name: 'title',
    mapping: 'title'
    },
    {
    name: 'type',
    mapping: 'type'
    },
    {
    name: 'ct',
    mapping: 'ct'
    },
    {
    name: 'state',
    mapping: 'state'
    }])
    });
    var gv = new Ext.grid.GridPanel({
    title: '问题列表',
    renderTo: document.body,
    width: 800,
    height: 500,
    autoScroll: true,
    loadMask: {
    msg: '正在加载数据,请稍侯……'
    },
    store: ds,
    columns: [new Ext.grid.RowNumberer(), {
    header: '标题',
    dataIndex: 'title',
    sortable: true
    },
    {
    header: '分类',
    dataIndex: 'type',
    sortable: true
    },
    {
    header: '时间',
    dataIndex: 'ct',
    sortable: true,
    renderer: Ext.util.Format.dateRenderer('Y.m.d')
    },
    {
    header: '回复状态',
    dataIndex: 'state',
    sortable: true
    }],
    bbar: new Ext.PagingToolbar({
    pageSize: 5,
    store: ds,
    displayInfo: true,
    displayMsg: 'Displaying topics {0} - {1} of {2}',
    emptyMsg: "No topics to display"
    })
    });
    ds.load({
    params: {
    start: 0,
    limit: 5
    }
    });
    });[/code]

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

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格