Extjs Grid中默认选中

在项目需要做个部门切换,在选中用户所在部门的列表中,要对默认选中当前登录的部门
数据已经出来了,但是同事提供过来的的只是默认选择第一条记录。我还是先查下文档,
在Ext.selection.Model里面有个
select( Ext.data.Model[]/Number records, [Boolean keepExisting], [Boolean suppressEvent] )

Selects a record instance by record instance or index.

可以通过index进行选择,而deptGrid.getSelectionModel()得到是Ext.selection.Model

因为一个用户所在的部门数量不多,所以在store里通过属性去查找当前所在的部门,获得该条记录的index,就可以实现默认选中。

Ext.data.Store


findRecord( String fieldName, String/RegExp value, [Number startIndex], [Boolean anyMatch], [Boolean caseSensitive], [Boolean exactMatch] ) : Ext.data.Model

Finds the first matching Record in this store by a specific field value.

When store is filtered, finds records only within filter.

Parameters

  • fieldName : String

    The name of the Record field to test.

  • value : String/RegExp

    Either a string that the field value should begin with, or a RegExp to test against the field.

  • startIndex : Number (optional)

    The index to start searching at

    Defaults to: 0

  • anyMatch : Boolean (optional)

    True to match any part of the string, not just the beginning

    Defaults to: false

  • caseSensitive : Boolean (optional)

    True for case sensitive comparison

    Defaults to: false

  • exactMatch : Boolean (optional)

    True to force exact match (^ and $ characters added to the regex).

    Defaults to: false

Returns

  可能这只是其中的一种方法,特此记录下来。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值