3
votes

I have column locking in my grid working successfully within my code with locked: true. And at runtime I can lock/unlock columns manually via the grid interface.

However I want a certain column to lock when a button is pressed. How do I lock a column dynamically/programmaticaly? I was expecting/hoping for a "setLocked" method, but that does not seem to exist?

1

1 Answers

3
votes

Grid has methods .lock(column) and .unlock(column).
For this grid with button on toolbar
enter image description here

button click listener is:

onClick: function(button) {
        var grid = button.up('grid');
        var column = grid.down('gridcolumn[text=column1]');
        if (column.locked) {
            grid.unlock(column);
        } else {
            grid.lock(column);
        }
}