现在的位置: 首页 > 综合 > 正文

Extjs Grid中默认选中

2013年02月01日 ⁄ 综合 ⁄ 共 1170字 ⁄ 字号 评论关闭
文章目录

在项目需要做个部门切换,在选中用户所在部门的列表中,要对默认选中当前登录的部门
数据已经出来了,但是同事提供过来的的只是默认选择第一条记录。我还是先查下文档,
在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

  可能这只是其中的一种方法,特此记录下来。

抱歉!评论已关闭.