setInterval,在线等

zhende21ke19 2011-08-15 01:49:53
我用ext建立一个js页面,数据都存在store里,想每个3秒自动刷新一下store,总提示我this.store未定义,求高手帮看看,万分感谢。
NSCC.Ext.View_Ctrl_Panel=Ext.extend(NSCC.Ext.ViewPanel,{
control:function()
{
var record=this.grid.getSelectionModel().getSelected();
if(!record)
{
Ext.Msg.alert("提示","请先选择要操作的盘阵!");
return;
}
window.open("http://"+record.get("ip"));
},

initComponent : function()
{
this.myrefresh = Ext.override(Ext.data.Store, {
startAutoRefresh : function(){
setInterval(this.reload(), 1000);
}
});

this.store = new Ext.data.JsonStore({
url: this.baseUrl+'?action=list',
root:"Result",
totalProperty:"totalProperty",
remoteSort:true,
fields:this.storeMapping
});
this.store.paramNames.sort="orderBy";
this.store.paramNames.dir="orderType";
this.cm.defaultSortable=true;
NSCC.Ext.ViewPanel.superclass.initComponent.call(this);
var viewConfig=Ext.apply({forceFit:true},this.gridViewConfig);

this.grid=new Ext.grid.GridPanel
(
{
store: this.store,
cm: this.cm,
trackMouseOver:false,
loadMask: true,
viewConfig:viewConfig,
tbar:
[' ',
{
text: '删除',
pressed: true,
handler: this.removeData,
scope:this
},' ',
{
text: '删除全部',
pressed: true,
handler: this.removeAllData,
scope:this
},' ',
{
text: '添加备注',
pressed: true,
handler: this.addnote,
scope:this
},' ',
{
text: '详细信息',
pressed: true,
handler: this.control,
scope:this
},' ',
{
text: '刷新',
pressed: true,
handler: this.search,
scope:this
},' ',
new Ext.Toolbar.Fill(),
{
xtype: 'textfield',
id:'queryText' + this.getId(),
width: 200,
allowBland :false,
emptyText: "请输入需要查询的IP地址",
listeners: {
'render': {fn:function(){
Ext.getCmp('queryText' + this.getId()).getEl().on('keyup',
function(){
this.search();
},
this,
{buffer:500}
);
},
scope:this}
}
}
],
bbar: new Ext.PagingToolbar
(
{
pageSize: 50,
store: this.store,
displayInfo: true,
plugins: new Ext.ux.ProgressBarPager()
}
)
}
);

this.grid.on("celldblclick",this.edit,this);
this.add(this.grid);
this.store.load({params:{start:0, limit:50}});
setInterval(function () {this.store.reload();}, 3000);
}
...全文
80 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhende21ke19 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 softroad 的回复:]

引用 1 楼 softroad 的回复:

setInterval(this.store.reload(), 3000);


这个代码不可以吗?
[/Quote]
不可以呀,告诉我this.store未定义呢,奇怪
softroad 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 softroad 的回复:]

setInterval(this.store.reload(), 3000);
[/Quote]

这个代码不可以吗?
zhende21ke19 2011-08-15
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 softroad 的回复:]

setInterval(this.store.reload(), 3000);
lz this指向的是function函数本身
[/Quote]
哦,我不太会js,那请问怎样才能在setInterval(function(){}, 3000);里调用this.store呢?谢谢
zhende21ke19 2011-08-15
  • 打赏
  • 举报
回复
哦,我不太会js,那请问怎样才能在setInterval(function(){}, 3000);里调用this.store呢?谢谢
softroad 2011-08-15
  • 打赏
  • 举报
回复
setInterval(this.store.reload(), 3000);
lz this指向的是function函数本身

50,503

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧