Toggle Button in Datatable

Hi, is it possible to add a toggle button ( http://docs.webix.com/desktop__controls.html#toggle ) to a datatable?

Hi,

Any Webix control can be added to a data component with the help of ActiveContent Module.

Check the sample, please http://webix.com/snippet/32b4e40b.

I added extra styling to the button to adjust its position in the grid cell.

Hi Helga,

Thanks a lot for your quick response.

I checked the Active Content docs and in an example I saw how one can get the row of a clicked button with the help of locate(). Unfortunately the toggle button doesn’t have an onClick handler. It only has an onChange handler with newv & oldv as parameters but no ID is provided.

Is there a way to get the datatable row of the currently clicked toggle button?

Hi,

I could fix my last problem by using “this.config.$masterId” within the onChange handler.
Is there a better way to do this?

I have yet another question:
Is there a way to access a specific button in a datatable when I know the row id? Using a form is very limiting in terms of design.

Still I tried to add two buttons to the same form and get access to the other button over the form but the icon toggle button doesn’t change its icon as shown in this example. Interestingly this works flawlessly if it isn’t called within a datatable. Any ideas why this is happening?

Thanks a lot for your help!

Hi,

Nice of you to find the way out. The thing is that you can’t use locate() with toggle button, as html changes (the button is redrawn as it changes its state) and event target is empty.

The ActiveContent module is not supposed for nesting layout elements, so mouse events may be handled incorrectly.

There’s no specific API to get to active content elements now, but you can access these buttons by working with html a bit. http://webix.com/snippet/ce303fb8

Hi Helga

Thanks a lot for your reply. I tried your approach and it only seems to work for me when the buttons are in the same datatable cell?
I think the topic of this thread is getting a bit more specific towards normal buttons, therefore I decided to open a new thread. I hope this is OK with you?