extjs grid 定时load_ExtJS用Grid显示数据后如何自动选取第一条记录

在使用ExtJS的Grid显示数据后,若要自动选取第一条记录,可以在Store的load方法的callback回调中实现。当加载成功且存在记录时,通过`getSelectionModel().select(0, true)`来选取第一条记录。" 111422646,10296659,Python IoC框架实践与反思,"['Python框架', '依赖管理', '设计模式', 'IoC容器', 'Flask开发']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用Grid显示数据后,如何让系统自动选取第一条记录呢?在显示Grid时由于其Store正在loading,没法在Grid选取第一条记录,因为还没有记录,所以应在其Store进行操作。

查看Ext.data.Store的load()方法如下:

load( [options] )

Loads data into the Store via the configured proxy. This uses the Proxy to make an asynchronous call to whatever storage backend the Proxy uses, automatically adding the retrieved instances into the Store and calling an optional callback if required. Example usage:

store.load({

scope:this,

callback:function(records, operation, success) {//the operation object

//contains all of the details of the load operation

console.log(records);

}

});

以下为重点

有一个callback函数,可以该回调函数中执行Grid选取第一条记录的操作。

Store.load({

callback: function(rec, oper, success){

if(success){

Ext.getCmp('Gridid').getSelectionModel().select(0,true);

}

}

});

callback: function(rec, oper, success){//回调

if(success && rec != undefined && rec != null && rec.length > 0){

gridPanel.getSelectionModel().select(0,true);

解释

gridPanel 当前的 Ext.grid.Panel值   getSelectionModel() 获取model层   select(0,true) 选择第一个参数

}

// 对象 operation 包含

// 所有 load 操作的详细信息

// dataList = Ext.JSON.decode(res);

// gridStore.loadData(dataList.data, false);

// gridPanel.down('pagingtoolbar').bind(gridStore);

me.unmask();

}

借鉴:https://blog.youkuaiyun.com/wilsonyun/article/details/46632129

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值