#master_checkbox special case improvement

We have found the possibility that, in the grids, columns defined as checkbox (ch), may have rows where the cell is not defined (is empty, without checkbox).
In these cases, when you press the master_check, does not take into account whether the cell is empty.
For these cases, the script should check if that is the case.

dhtmlXGridObject.prototype._in_header_master_checkbox_a = function(t, i, c) {
    t.innerHTML = c[0] + "<input type='checkbox' />" + c[1];
    var self = this;
    t.firstChild.onclick = function(e) {
        var j = self._m_order ? self._m_order[i] : i;
        var val = this.checked ? 1 : 0;
        var max = self.getRowsNum();
        for (var ind = 0; ind < max; ind++) {
            var c = self.cells2(ind, j);
            if (c.isCheckbox() && c.cell.innerHTML.indexOf("img") !== -1) {
        (e || event).cancelBubble = true;

The changes in line

if (c.isCheckbox()){
if (c.isCheckbox() && c.cell.innerHTML.indexOf("img") !== -1) {

should do the magic.

Maybe, in the future, you can implement this improvement in your scripts.

Thank you for your note.
Your solution will be considered.

Your solution is considered but it won’t be added to the future versions of dhtmlxgrid.
It’s not guaranteed that it will work correctly in all situations.

Unfortunately the keeping the cell empty is not common for a checkbox column.
The primary way for this situation is to change the exCell type for this cell:

Thanks for your answer.

I would like to know in which situations you found this solution didn’t work.

Just for my information.

Again, thank you very much.

Waiting for your response,

Ricardo V.

Please, refer to the following example:
dhtmlx.com/docs/products/dht … d_api.html
In any parent row (Honda, BMW,…) open the editor of the “Volume” column, then press TAB key to go to the next cell of the row. Now if you press the “Space” key you will check that “invisible” checkbox in the “State A” column and it appears in the grid.

For this case we use the following code in the creation of the grid.

grid.attachEvent('onKeyPress', function(code, cFlag, sFlag) {
                if (code == 32) { return false; }

So, we disable the pulsations of the “Space” key.
In this way, we force the user to use the mouse to operate the checkbox.
It’s not the perfect compromise but rather fits what we need.


Ricardo V.

On the other hand, you have suggested that we change the cell type to “ro”.

How would you do that to make the #master_checkbox function work?

We have tried to insert both checkbox and the html content from td, but has failed us.

Suggestion was to set the “ro” type to the cells in the checkbox column, where you don’t need to have checkbox.

Ok, now I understand it.