Loop common.checkbox()

Hi,

when I have a datatable with column that contains common.checkBox() in all lines, how can I check which are selected. I tried with node but node works only for visible lines and this table has to be scrolled and selected lines may dissapear from view. Is there a prepared function that collects all selected lines or how can I loop checkboxes…

Yeah, this was hard to solve but solution is easy to understand :slight_smile: It’s just hard to figure it out for the first time…

Everything begins with the data. You have to prepare the data and add same attribute as your column id and as attribute value is state of your checkbox (true, false or 1,0 etc) When you want to loop the checkboxes you just grab table data and use your attribute to find if it is selected or not.

My example:

I use JSON data: {…“checked”: false…},{…“checked”:true…}

datatable column: {id:“checked”, template:"{common.checkbox()}", editor:“checkbox”,checkValue:true, uncheckValue:false}…

and button attachEvent: AllData = datatable.data.pull

You can then loop the object with jquery

$.each(AllData , function(index,value){if (value.checked) {…collect in some variable}})

Yep, the above solution is fine, but you can do the same through component API as well

  • use eachRow method to iterate through all rows
  • check related property of item object

http://webix.com/snippet/cae4d8ff

Yeah. That’s even better :slight_smile:

Thanks.