Panel迟加载的方法(基本解决)

最近在研究Ext,做了一个ajax调取后台数据再显示出来的demo.
在Panel中要用到store中的数据.
请问如何才能让panel在store.load后才表现出来.谢谢

下面是部分代码

show.jsp

Ext.onReady(function(){
if (newsid==''){
Ext.Msg.alert('抱歉','您所输入的文章不存在或已被删除',function(){
history.go(-1);
}
);
};

var store = new Ext.data.JsonStore({
url: 'ajax.jsp?rpc=getnews&id='+newsid,
root: 'root',
fields: ['n_ttitle','n_content',{name:'n_time', type:'date'}],
autoLoad:true
});
var p = new Ext.Panel({
title:'标题',
//title:store.getAt(0).get('n_ttitle'),如果store还未加载就会出错
collapsible:true,
width:800,
html:'文章在这里\u002F'
//html:store.getAt(0).get('n_content'),文章内容
});
p.render('content');
});


后台传过来的数据

{ "root": [{'n_ttitle': '文章标题 ','n_content': '文章内容','n_time': '2008-3-10 14:47:42'}]
}


以下是解决方案:
[quote="gdyxml2000"]加上如下代码:
store.on('load', function(_store, _records, _options){
var title = _records[0].get('n_ttitle');
var content = _records[0].get('n_content');
p.setTitle(title);
p.html = content;
p.doLayout();
});[/quote]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值