Ext.TaskMgr.start({
interval: 1000, //runs every 1 sec
run: function() {
Ext.Ajax.request({
url: 'ajaxGetRecords.action',
params: '',
//success: function(form, action){
success: function(response , options ){
var arr = Ext.decode(response.responseText).root;
for(var i=0;i<arr.length;i++){
user = new Users({
userId: arr[i].userId,
userName: arr[i].userName
});
ds.insert(0,user);
}
}
});
以上是ajax从后台取数据的代码,目前我是放在一个按钮的click上,怎么让在进入页面马上就开始每隔1秒读一次?谢谢
我的意思是这段代码应该放在页面的什么位置。
[b]问题补充:[/b]
顺便问一下ds.remove()的参数是什么
user = new Users({
userId: arr[i].userId,
userName: arr[i].userName
});
ds.remove(user);//这个报错,好像是索引有问题
[b]问题补充:[/b]
getAt( Number index ) : Ext.data.Record
Get the Record at the specified index.
getById( String id ) : Ext.data.Record
Get the Record with the specified id.
query( String field, String/RegExp value, [Boolean anyMatch], [Boolean caseSensitive] ) : MixedCollection
Query the records by a specified property.
queryBy( Function fn, [Object scope] ) : MixedCollection
Query the cached records in this Store using a filtering function. The specified function will be called with each re...
根据某个函数,和你的值,找到这个record先,然后再remove
这里面的参数,比如ID,我去哪里找,是我的userId吗?
[b]问题补充:[/b]
我在ds.getById(userId)取不到值