Datatable, select row onclick and unselect when click

Hi,

I don’t get it, I don’t know what I’m doing wrong.

I need that when the user clicks on a row it is selected and when they click on a selected row it is deselected. I can’t use ctrl + click, but I need the same effect with a mouse click.

Thanks in advance.

Hello @JAP,
As a solution, you can use the ready handler function and redefine on_click.webix_cell event:

 ready: function(){
            this.on_click.webix_cell = function(e, id){
                if(this.isSelected(id))
                    this.unselect(id)
                else {
                    this.blockEvent();
                    this.unselectAll();
                    this.unblockEvent();
                    this.select(id,true)
                }
            };
        },

Please take a look at the snippet:
https://snippet.webix.com/a5zq64c8

@annazankevich,Thank you very much, but I need it to be multiselect, to be able to have more than one selected row, there is the possibility without using ctrl + click, even in the example ctrl + click it does not work

@annazankevich ,If I comment that line “//this.unselectAll();” I have just what I wanted, thank you very much again