Kam*_*ngh 3 angularjs angular-ui angular-ui-grid angular-ui-select
如何在角度ui.grid中找到已排序的列和按什么顺序排列.其实我想设置基于服务器的分页.为此,我将params中的数据发送为{pageNumber,pageSize,column,order}.现在如何找到用户已经排序的列(名称/年龄/数字)以及角度ui.grid中的顺序(ASC/DESC)
fpa*_*one 10
当列已排序时,Angular ui-grid会启动sortChanged事件.您还必须明确设置useExternalSorting为true.
您可以在onRegisterApi函数的gridOptions中捕获此事件,并在回调函数中处理排序逻辑,该函数将网格和排序列数组作为参数,如下所示:
$scope.gridOptions = {
useExternalSorting: true,
columnDefs: [
...
],
onRegisterApi: function( gridApi ) {
$scope.gridApi = gridApi;
$scope.gridApi.core.on.sortChanged( $scope, function(grid, sortColumns){
// sortColumns is an array containing just the column sorted in the grid
var name = sortColumns[0].name; // the name of the first column sorted
var direction = sortColumns[0].sort.direction // the direction of the first column sorted: "desc" or "asc"
// Your logic to do the server sorting
});
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7523 次 |
| 最近记录: |