1

I have the following jsfiddle that generates a YUI Datatable with checkboxes, but i have a problem getting the data of ids from the table after i click the Get Records button.

anyway to call the table from the javascript?

P.S : I am using YUI2 library as my project is using that

jonleech
  • 461
  • 1
  • 6
  • 30

1 Answers1

1

Using Checkbox Listeners

I hope this codes show what you need http://yuilibrary.com/yui/docs/datatable/datatable-chkboxselect.html

Edit:

I update your code for adding checkboxClickEvent for handling checkbox event in each of data row and use an array to keep all of the checked record id.

var selectedID = [];

myDataTable.subscribe("checkboxClickEvent", function(oArgs){ 
                alert("check box clicked");
                var elCheckbox = oArgs.target; 
                var oRecord = this.getRecord(elCheckbox); 
                if (elCheckbox.checked) {
                    selectedID.push(oRecord.getData("id"));
                } 
                else {
                    selectedID.pop(oRecord.getData("id"));
                }
                oRecord.setData("check",elCheckbox.checked); 
            }); 

Detail of working code is here.

swemon
  • 5,840
  • 4
  • 32
  • 54
  • this is somewhat similar but i have difficulties trying to relate my `YUI datatable` to the button, as i only need to show the table if there are results thus the need for the `innerHTML` portion to replace with the `YUI datatable` – jonleech Oct 02 '12 at 06:02
  • nvm it seems that i can just declare a var at the top of the page but it seems so untidy.. – jonleech Oct 02 '12 at 06:11
  • it seems that the `checkboxClickEvent` is giving me problems, is there any code for the `checkboxClickEvent` that can be used to correctly select the row that the checkbox is in? – jonleech Oct 02 '12 at 08:21
  • I update your code that it only use YUI button and array to keep checked id. Please check my code. Hope it helps. – swemon Oct 02 '12 at 08:29
  • thank you so much. i think this way its easier than for me. Its weird that my code somehow was broken when i post it the `checkboxClickEvent` was not working – jonleech Oct 02 '12 at 08:42