How to get the checked value of checkboxes from datatable ?

Hi,

The last column of my datatable has a button for all the cells which opens a popup datatable. That popup datatable is having a list of names along with checkboxes.

By clicking on that button, I may select/check any, none or all of the items from that popup datatable by using those checkboxes.

In the end when I download them by the download button , I want values of those check boxes to be appended to the lines I write to the downloaded file.

For example if 'a' and 'd' are selected the line should look like below:

line = Smith | place1 | a,d

However, I am not able to get the checked values from the popup table in the saveValues() function.

Snippet:https://snippet.webix.com/y7w0uera

Thanks.

Comments

  • Hi,
    I could get the checked values from the popup datatable. But while downloading only the last selected checkbox values are coming . All the earlier selection is getting overwritten.

    Snippet: https://snippet.webix.com/5l90h4zf

    how can I get appropriate selection of checkbox for each row ?

  • Hello @ovi_zit ,
    Actually, to get the value of checkboxes you need to use eachRow method to iterate through all rows

    $$("datatable").eachRow(function(id){ 
      if (this.getItem(id).ch1) 
        console.log(id+" is checked");
    })
    

    But while downloading only the last selected checkbox values are coming . All the earlier selection is getting overwritten.

    The problem is that you use id of datatable again and again, so your values are rendered and that's why the last check is the result
    As a solution, please use

     r.id3.forEach(function(obj){
          if(obj.ch1 == "on")
            str += obj.pid1+",";
        })
    

    Example: https://snippet.webix.com/jvbvbjtc

  • Wonderful solution Nastja!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion