Rally grid color rows based on model

我只是一个虾纸丫 提交于 2019-12-04 05:43:29

问题


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?

I have tried:

viewConfig: {
    getRowClass: function(record, index, rowParams, store) {
        console.log('record',record); // nothing logged in console
        console.log('index',index);
        return 'colorCodeGrid'; // class never added
    }
},

[EDIT]

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
    }
},

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.


回答1:


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.

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.

[EDIT by asker] 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
        };
    }
},

UPDATE:

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.



来源:https://stackoverflow.com/questions/17867436/rally-grid-color-rows-based-on-model

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!