Our blazing fast Grid component built with pure JavaScript


Post by notepads »

We just need "row:true" in the section in the feature to show the checkbox on the grid. It is showing checkbox on every row of the grid table. What if I don't want to show the check box for a particular row. Is there any way?

Thank you for your support.


Post by arcady »

That can be done smth like this:

let i = 0;

// subclassing grid to override its check column renderer
class MyGrid extends Grid {
    afterConfigure() {
        super.afterConfigure(...arguments);

        const
            // get check column instance and its render function
            column         = this.columns.find(c => c.isCheckColumn),
            columnRenderer = column.renderer;

        // override renderer function to show checkbox conditionally
        column.renderer = function({ record }) {
            // if i-value is odd then show checkbox by calling the original renderer
            if (i++ % 2) {
                return columnRenderer(...arguments);
            }
            else {
                return '';
            }
        };
    }
}

const grid = new MyGrid({
    ...

To have more info on how that checkbox is added to the Grid and how to hack it please check GridSelection mixin source code.


Post Reply