Count selected row
Count selected row
LArmstrong85
Posts: 21Questions: 14Answers: 0
Hi,
I have a datatable to which I added a column with a checkbox. I would be able to
count the number of checkbox selected and save in an array a list of this rows, but
I have a problem with the checkbox click event in Jquery.
Can you help me?
This is a little example that differ with mine only in the fact that in my project I use Ajax source data.
(I don't know how i can do it in live.datatable.net).
http://live.datatables.net/qisogeje/7/edit
Thank you in advance!
This discussion has been closed.
Answers
You are executing your function there. So what jQuery sees is really:
since your function isn't returning anything.
I think what you want is:
You should also use
$()
to query all rows in the table, not just those on the current page.Allan
Thank you Allan.
I tried your suggestion but it doesn't work, Can you give me an example please?
Hi Allan,
i retrieve a solution for count the number of row selected.
This is the example even if it doesn't work in live.datatable (in my pc it works!)
http://live.datatables.net/qisogeje/9/edit
I also need to collect all checked row and send to server in JSON format.
How I can do it?
Thank you very much!
You could use the same approach as in this example.
Allan
Ok,
this is the same solution that I had in my mind. On click on combobox I would to add a class selected on table rows for retrieve them like the example. But how I can retrieve the corresponding row that I have selected in my click handler?
Assuming your event handler is targeting a descendent of the row you would just use a little bit of jQuery:
$(this).closest('tr')
.Allan