gpt4 book ai didi

javascript - angularJS 不根据 NG-Grid 中的值显示行

转载 作者:行者123 更新时间:2023-11-28 00:41:51 27 4
gpt4 key购买 nike

我是 angularJS 广告新手,如果某列的值为“0”,我被要求隐藏 ng-grid 表中的一行。

我的网格有4列:

  • 用户
  • 今天
  • 本周
  • 本月

如果“本月”列为“0”,我想隐藏整行

我的gird HTML 是:

<div data-ng-controller="workflowworkitemscompleted as vm">
<div data-ng-if="isbusy">
<div data-cc-spinner="vm.spinnerOptions"></div>
</div>
<div class="row">
<div class="col-md-12">
<div class="gridStyle" style="height:157px" data-ng-grid="gridOptions" id="cwigrid"></div>
</div>
</div>
</div>

我的 Controller 代码是:

$scope.searchfilter = "";
$scope.mySelections = [];
$scope.sortInfo = { fields: ['countDay'], directions: ['desc'] };
$scope.totalServerItems = 0;
$scope.pagingOptions = {
pageSizes: [5],
pageSize: 5,
currentPage: 1
};

$scope.gridOptions = {
data: 'wfiprocessed',
multiSelect: false,
rowHeight: 25,
showFooter: false,
footerRowHeight: 40,
enableColumnReordering: false,
showColumnMenu: false,
enableColumnResize: false,
enableRowSelection: false,
filterOptions: $scope.filterOptions,
selectedItems: $scope.mySelections,
enablePaging: false,
pagingOptions: $scope.pagingOptions,
plugins: [gridLayoutPlugin],
totalServerItems: 'totalServerItems',
sortInfo: $scope.sortInfo,
useExternalSorting: false,
virtualizationThreshold: 50,
rowTemplate: "<div ng-style=\"{ 'cursor': row.cursor }\" ng-repeat=\"col in renderedColumns\" class=\"ngCell {{col.colIndex()}} {{col.cellClass}}\">" +
" <div class=\"ngVerticalBar\" ng-style=\"{height: rowHeight}\" ng-class=\"{ ngVerticalBarVisible: !$last }\">&nbsp;</div>" +
" <div ng-cell></div>" +
"</div>",
columnDefs: [
{ field: 'userName', displayName: 'User', cellTemplate: vm.optimizedcell },
{ field: 'countDay', displayName: 'Today', cellTemplate: vm.optimizedcell },
{ field: 'countWeek', displayName: 'This Week', cellTemplate: vm.optimizedcell },
{ field: 'countMonth', displayName: 'This Month', cellTemplate: vm.optimizedcell }
]
};

我的 table 看起来像: enter image description here

查看上表,我不希望显示“dtealdev”或“qauser2”行,因为“本月”列为“0”

最佳答案

$scope.gridOptions 的数据源中,您可以提供要在网格中显示的所有数据集。您所做的是,您也在该数据集中传递了不需要的字段,即 qauser2dtealedev

您可以做的就是仅返回需要显示的所需数据值集。

$scope.gridOptions.data = function(data) {
//remove the items in data that contain 0 in all fields

return newData;
}

关于javascript - angularJS 不根据 NG-Grid 中的值显示行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27838775/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com