如何设置总是选择第一行 ui-grid
how to set always selected first row ui-grid
我通过 api 和教程寻找这个函数,但只找到 select 第一个网格初始化中的第一行,
gridApi.selection.selectRow($scope.gridOptions.data[0]);
我试图在 onRegisterApi
或过滤器函数
中使用此功能
$scope.filter = function() {
$scope.gridApi.grid.refresh();
$scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);
}
$scope.singleFilter = function( renderableRows ){
var matcher = new RegExp($scope.filterValue);
renderableRows.forEach( function( row ) {
var match = false;
[
// 'id',
// 'study.name',
'title',
'occuredDate',
// 'eventType.name',
'description',
'createdDate' ,
// 'priority.name',
'severity.name',
'status.name',
'createdDate'
].forEach(function( field ){
if (field.indexOf('.') !== '-1' ) {
field = field.split('.');
}
if ( row.entity.hasOwnProperty(field) && row.entity[field].match(matcher) || field.length === 2 && row.entity[field[0]][field[1]].match(matcher)){
match = true;
}
});
if ( !match ){
row.visible = false;
}
});
return renderableRows;
};
但没有任何帮助。我需要始终对第一行进行 select 编辑,即使我通过列过滤器或使用单个过滤器过滤数据也是如此。在 ui-grid 中可以吗?
我通过 api 和教程寻找这个函数,但只找到 select 第一个网格初始化中的第一行,
gridApi.selection.selectRow($scope.gridOptions.data[0]);
我试图在 onRegisterApi
或过滤器函数
$scope.filter = function() {
$scope.gridApi.grid.refresh();
$scope.gridApi.selection.selectRow($scope.gridOptions.data[0]);
}
$scope.singleFilter = function( renderableRows ){
var matcher = new RegExp($scope.filterValue);
renderableRows.forEach( function( row ) {
var match = false;
[
// 'id',
// 'study.name',
'title',
'occuredDate',
// 'eventType.name',
'description',
'createdDate' ,
// 'priority.name',
'severity.name',
'status.name',
'createdDate'
].forEach(function( field ){
if (field.indexOf('.') !== '-1' ) {
field = field.split('.');
}
if ( row.entity.hasOwnProperty(field) && row.entity[field].match(matcher) || field.length === 2 && row.entity[field[0]][field[1]].match(matcher)){
match = true;
}
});
if ( !match ){
row.visible = false;
}
});
return renderableRows;
};
但没有任何帮助。我需要始终对第一行进行 select 编辑,即使我通过列过滤器或使用单个过滤器过滤数据也是如此。在 ui-grid 中可以吗?