1
フィルタを適用した後に最初の行を選択することはできません。したがって、最初の行を選択するページをロードするときには、私は次のものを使用します:フィルタの後に最初の可視行を選択する
gridApi.selection.selectRow($scope.gridOptions.data[0]);
これはAPIドキュメントからのものです。 フィルタの後に最初の行を選択しようとしています。 私は公式ドキュメントから来singleFilter機能を持っている
私は私は、最初の行 var first = function(array, n) {
if (array == null){
return void 0;
}
if (n == null) {
return array[0];
}
if (n < 0) {
return [];
}
return array.slice(0, n);
};
console.log(first(rows))
を取得
var rows = $scope.gridApi.core.getVisibleRows();
簡単なスクリプトスルー表示される行の長さを取得
$scope.singleFilter = function(renderableRows){
var matcher = new RegExp($scope.filterValue);
renderableRows.forEach(function(row) {
var match = false;
[
'name', 'company', 'email'
].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;
}
});
var rows = $scope.gridApi.core.getVisibleRows();
var first = function(array, n) {
if (array == null){
return void 0;
}
if (n == null) {
return array[0];
}
if (n < 0) {
return [];
}
return array.slice(0, n);
};
console.log(first(rows))
$scope.gridApi.selection.selectRow(first(rows));
return renderableRows;
};
選択をしようとしています
$scope.gridApi.selection.selectRow(first(rows));
しかし、残念ながら成功はありません。私のミスはどこですか?私はどんな助けにも感謝します。 My plunker
魔法のように動作します!ちょっと待っては、あなたの説明をありがとう、私はそれを感謝! – Anton