基于模型的拉力网格颜色行 [英] Rally grid color rows based on model
问题描述
我有一个被配置为显示两个模型的rallygrid:PortfolioItem/Feature 和PortfolioItem/Rollup.我想在网格中给它们着色以区分它们.我不知道它们会在网格中交替出现,或类似的东西.我只想对汇总应用一种微妙的颜色,以在视觉上区分它们.
I have a rallygrid that is configured to display two models: PortfolioItem/Feature and PortfolioItem/Rollup. I want to color them in the grid to differentiate them. I am not garunteed that they will alternate in the grid, or anything like that. I just want to apply a subtle color to the rollups to differentiate them visually.
谁能想到一个简单的方法来实现这一目标?
Can anyone think of an easy way to achieve this?
我试过了:
viewConfig: {
getRowClass: function(record, index, rowParams, store) {
console.log('record',record); // nothing logged in console
console.log('index',index);
return 'colorCodeGrid'; // class never added
}
},
viewConfig: {
stripeRows: false, // rows are no longer striped
getRowClass: function(record, index, rowParams, store) {
console.log('record',record); // still nothing logged in console
console.log('index',index);
return 'colorCodeGrid'; // class never added
}
},
令我感到奇怪的是,viewConfig 正确地取消了行的条带化,但从未调用过 getRowClass.我想可能只是 viewConfig 作为一个整体没有被使用在一个拉力网格的情况下.
It is strange to me that the viewConfig does correctly un-stripe the rows, but the getRowClass never gets called. I thought maybe just the viewConfig as a whole was not being used in the case of a rallygrid.
推荐答案
您上面使用 viewConfig 的方法应该可行 - 我将就此提出缺陷.根本原因是 Rally.ui.grid.GridView 在其构造函数中删除了 getRowClass 函数(用于内部浏览器测试目的 - 呃),而不是检查是否提供并调用它.
Your approach above with the viewConfig should work- I am going to file a defect on this. The root cause is that the Rally.ui.grid.GridView is blowing away the getRowClass function in its constructor (for internal browser testing purposes- ugghh) rather than checking if there was one supplied and calling that as well.
您可以在此处查看构造函数的源代码:https://developer.help.rallydev.com/apps/2.0rc1/doc/source/GridView.html#Rally-ui-grid-GridView
You can see it the source for the constructor here: https://developer.help.rallydev.com/apps/2.0rc1/doc/source/GridView.html#Rally-ui-grid-GridView
您应该能够通过在呈现视图之前重新覆盖该函数来解决它.
You should be able to work around it by just re-overriding the function before the view is rendered.
[由提问者编辑]将以下内容添加到网格中,它起作用了:
Added the following to the grid, and it worked:
listeners: {
beforerender: function(cmp) {
console.log('beforerender');
console.log('view',cmp);
cmp.view.getRowClass = function(record, index, rowParams, store) {
console.log('record',record); // still nothing logged in console
console.log('index',index);
return 'colorCodeGrid'; // class never added
};
}
},
更新:
我刚刚在每晚构建中修复了这个问题,所以从 2.0rc2 之后的下一个公开版本开始,这应该不再是公共 sdk 构建中的问题.
I just fixed this in the nightly build, so this should no longer be an issue in public sdk builds beginning with the next public release after 2.0rc2.
这篇关于基于模型的拉力网格颜色行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!