数据已经出来了,但是同事提供过来的的只是默认选择第一条记录。我还是先查下文档,
在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,就可以实现默认选中。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
- Ext.data.Model
The matched record or null