Master checkbox control in datatable

hi, I have this code : Code Snippet

Now I can control the checkbox of the current page with the master checkbox.
But I still have problems. Can someone tell me how?
when I uncheck one row, the master checkbox should also be unchecked.
And when I checked all rows on the current page, the master checkbox should be checked too.

In fact, the code that controls the master checkbox was copied from an old post in webix forum.
Can I possibly simplify this code?
Please let me know if there is a simple way in the updated version.
(I don’t understand this code yet. Sorry.)

Thank you.

Hello!

Please, check the following snippet: Code Snippet

Can I possibly simplify this code?

Unfortunately, for now, there’s not much you can do to make it simpler

1 Like

Thank you @NastassiaM

Unfortunately, when I apply the same to my code, It’s not working.
Can you tell me why? Did I miss anything?

https://snippet.webix.com/pw88zhcz

In my code, I can control the checkbox with item click (Select).

 onItemClick: function(id) {
		var item = this.getItem(id);
		item.checked = !item.checked;
		this.updateItem(id.row, item);	
	},

this is just chaneges the row’s checkbox ,
and it doesn’t affect the master checkbox.

What should I do?

Hi!

You can place this part of logic into checkMaster function

onCheck: function (row, column, state) {
         if (state) {
            this.select(row, true);
          }
     	else {
        	this.unselect(row);
      	}
    },

And leave onCheck like this:

onCheck: checkMaster

Here’s the result: Code Snippet

1 Like

Thank you for your kindness !! :heart_eyes: