Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/158.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 如何在UI网格';页脚_Angularjs_Angular Ui Grid_Ui Grid - Fatal编程技术网

Angularjs 如何在UI网格';页脚

Angularjs 如何在UI网格';页脚,angularjs,angular-ui-grid,ui-grid,Angularjs,Angular Ui Grid,Ui Grid,有没有办法在UI网格中获取自定义总计 例如,我有以下几点 我只想把特里·克莱和尼维斯·麦克这两个名字的行加起来,并将其显示为一个总数。例如:我想要一个特定行数的总和。这可行吗?我一直在寻找一种方法来实现这一点,并访问了customtreeaggegationfn和customtreeaggegationfinalizerfn,如图所示。但是,我不确定如何访问这些特定行中的值以将它们相加并显示为页脚的一部分 这是Plunkr中的代码 $scope.gridOptions = { showG

有没有办法在UI网格中获取自定义总计

例如,我有以下几点

我只想把特里·克莱和尼维斯·麦克这两个名字的行加起来,并将其显示为一个总数。例如:我想要一个特定行数的总和。这可行吗?我一直在寻找一种方法来实现这一点,并访问了
customtreeaggegationfn
customtreeaggegationfinalizerfn
,如图所示。但是,我不确定如何访问这些特定行中的值以将它们相加并显示为页脚的一部分

这是Plunkr中的代码

$scope.gridOptions = {
    showGridFooter: true,
    showColumnFooter: true,
    enableFiltering: true,
    columnDefs: [
        { field: 'name', width: '13%' },
        { field: 'address.street',aggregationType: uiGridConstants.aggregationTypes.sum, width: '13%' },
        { field: 'age', aggregationType: uiGridConstants.aggregationTypes.avg, aggregationHideLabel: true, width: '13%' },
        { name: 'ageMin', field: 'age', aggregationType: uiGridConstants.aggregationTypes.min, width: '13%', displayName: 'Age for min' },
        { name: 'ageMax', field: 'age', aggregationType: uiGridConstants.aggregationTypes.max, width: '13%', displayName: 'Age for max' },
        { name: 'customCellTemplate', field: 'age', width: '14%', 
          customTreeAggregationFn : function( aggregation, fieldValue, numValue, row ) {
          if(row.entity.name.value === 'Terry Clay' || row.entity.name.value === 'Nieves Mack'){
           aggregation.value += row.entity.age;
          }
          },
          customTreeAggregationFinalizerFn: function( aggregation ) {
           aggregation.rendered = aggregation.value;
          }
        },
        { name: 'registered', field: 'registered', width: '20%', cellFilter: 'date', footerCellFilter: 'date', aggregationType: uiGridConstants.aggregationTypes.max }
    ],
    data: data,
    onRegisterApi: function(gridApi) {
            $scope.gridApi = gridApi;
    }
};

请帮忙,我在UI网格方面遇到了很多问题,而且它缺乏支持,所以希望这里不是这样。

我设法解决了这个问题。为了添加特定的行,我编写了一个函数来返回它

这是它的代码

$scope.gridOptions = {
    showGridFooter: true,
    showColumnFooter: true,
    enableFiltering: true,
    columnDefs: [
        { field: 'name', width: '13%' },
        { field: 'address.street',aggregationType: uiGridConstants.aggregationTypes.sum, width: '13%' },
        { field: 'age', aggregationType: uiGridConstants.aggregationTypes.avg, aggregationHideLabel: true, width: '13%' },
        { name: 'ageMin', field: 'age', aggregationType: uiGridConstants.aggregationTypes.min, width: '13%', displayName: 'Age for min' },
        { name: 'ageMax', field: 'age', aggregationType: uiGridConstants.aggregationTypes.max, width: '13%', displayName: 'Age for max' },
        { name: 'customCellTemplate', field: 'age', width: '14%', 
          aggregationType: function ()
          {
            if(!$scope.gridApi)
                return 0;
            var sum = 0;

            //if it is filtered/sorted you want the filtered/sorted rows only)
            var visibleRows = $scope.gridApi.core.getVisibleRows($scope.gridApi.grid);

            for (var i = 0; i < visibleRows.length; i++) {
              if(visibleRows[i].entity.name === 'Sandoval Mclean' || visibleRows[i].entity.name === 'Nieves Mack') {

                  //you have to parse just in case the data is in string otherwise it will concatenate
                  sum += parseInt(visibleRows[i].entity.age);
              }
            }
            return sum;
          },
        },
        { name: 'registered', field: 'registered', width: '20%', cellFilter: 'date', footerCellFilter: 'date', aggregationType: uiGridConstants.aggregationTypes.max }
    ],
    data: data,
    onRegisterApi: function(gridApi) {
            $scope.gridApi = gridApi;
    }
};
$scope.gridOptions={
showGridFooter:true,
showColumnFooter:是的,
启用筛选:正确,
columnDefs:[
{字段:“名称”,宽度:“13%”,
{字段:'address.street',aggregationType:uiGridConstants.aggregationTypes.sum,宽度:'13%'},
{字段:'age',aggregationType:uiGridConstants.aggregationTypes.avg,aggregationHideLabel:true,宽度:'13%',
{name:'ageMin',field:'age',aggregationType:uiGridConstants.aggregationTypes.min,width:'13%',displayName:'age for min'},
{name:'ageMax',field:'age',aggregationType:uiGridConstants.aggregationTypes.max,width:'13%',displayName:'age for max'},
{名称:'customCellTemplate',字段:'age',宽度:'14%,
aggregationType:函数()
{
if(!$scope.gridApi)
返回0;
var总和=0;
//如果已筛选/排序,则只需要筛选/排序的行)
var visibleRows=$scope.gridApi.core.getVisibleRows($scope.gridApi.grid);
对于(变量i=0;i
aggregationType
函数是我只添加具有特定名称的行的神奇之处