angularjs - Ag-grid 显示行数

标签 angularjs ag-grid

我正在测试企业版,我想知道是否可以在状态栏行中显示一些自定义文本? (如果状态栏不可用,是否有替代方法?)

我要展示X rows / Y total rows表,或者如果不可能,只需 X rows
或者Indicators: Blue - Manual Deposit, Red - Failed Deposit, Green - Success(在此示例中使用自定义样式显示颜色)

这可能吗?
(顺便说一句,我正在使用 Angular 1)

最佳答案

你问了 2 个不同的问题,我会试着解释这两个问题。

I want to show X rows / Y total rows of the table



您有 Y total rowsgridOptions.api.getModel().getRowCount() . X rows我假设指的是“当前显示的行”,我认为目前没有获得它的方法。不过我们曾经是这样,所以我可能是错的。

Indicators: Blue - Manual Deposit, Red - Failed Deposit, Green - Success



我猜您是在谈论更改单元格/行样式?有关单元格样式,请查看 Column Definition cellClassRules .从网页:

ag-Grid allows rules to be applied to include certain classes. If you use AngularJS, then this is similar to ng-class, where you specify classes as Javascript object keys, and rules as object values.



你可以像这样使用它:
//'Success', 'Manual' and 'Failed' are placeholders for the actual values
// you must compare to.
cellClassRules: {
    'green': function(params) { return params.value === 'Success'},
    'blue': function(params) { return params.value === 'Manual'},
    'red': function(params) { return params.value === 'Failed'}
},

对于整行样式,您可以使用 what I explained in this other question 实现它
// Again, 'Success', 'Manual' and 'Failed' are placeholders 
// for the actual values you must compare to.
gridOptions.api.getRowStyle(params) {
    switch(params.data.myColumnToCheck){
        case 'Success':
            return {'background-color': 'green'};
        case 'Manual':
            return {'background-color': 'blue'};
        case 'Fail':
            return {'background-color': 'red'};
    }
    return null;
}

关于angularjs - Ag-grid 显示行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36567018/

相关文章:

ag-grid - 在 ag-grid 中渲染 svelte 组件

ag-grid - Ag 网格 - 主/细节 - 多细节

javascript - 可以访问 ng-repeat 创建的范围项吗?

angularjs - ng-model 和 ng-options 不匹配?

java - 如何使用 AngularJS 使用 war 名称发送请求?

javascript - AngularJS 应用程序出现奇怪的路由错误

angularjs - Ag-grid 主详细信息防止详细信息行在数据刷新时关闭

python - 如何编辑Streamlit AgGrid行的单元格?

angular - Ag-grid(Angular 2) 无法访问 CellRenderer 中的组件字段

javascript - 为什么我在 JSON.stringify(value, replacer) 中的替换函数在 Angular 应用程序中没有收到 key ?