SlickGrid setting row opacity

2020-06-06 06:55发布

问题:

I am using SlickGrid and am wondering if there is a way to set and keep a rows opacity or css styles in general.

For example my rows have a checkbox in them and when the user sets the checkbox to checked then the opacity of the row is set. However when the user then clicks off the row the SlickGrid removes the opacity setting.

One option if anyone knows how to do it is to set the opacity of the row after SlickGrid has done its re-render. this would allow me to use the jQuery below across the entire grid:

$('img[src="slickgrid/images/tick.png"]').parent().parent().css('opacity','0.4');

回答1:

Just in case anyone else is trying to do something similar, I added a post render event by doing the following: Added a new method to the API section of SlickGrid and then subscribed to that method and implemented the jQuery to updated the opacity. I then triggered the method inside the render() method of SlickGrid.

To be a bit more clear:

In the slick.grid.js in the "Public API" section i added a new event:

"onPostRenderJob": new Slick.Event(),

I then updated the render() function in the same file:

function render() {
        // all the standard code here...
        trigger(self.onPostRenderJob);
    }

In the page that configures the grid i subscribed to the event:

 grid.onPostRenderJob.subscribe(function(e, args) {
                $('img[src="slickgrid/images/tick.png"]').parent().parent().css('opacity', '0.4');
            });


回答2:

This accepted answer is absolutely wrong, but I don't blame the author since this was posted over 2 years ago and on for a really old version of SlickGrid.

Please see https://github.com/mleibman/SlickGrid/wiki/Providing-data-to-the-grid for information on how to do this properly without killing performance.