Datatable rows recorder
Datatable rows recorder
Hello, I am consuming an API that returns 98 elements, each row has a button. I need to go through each of the rows and depending on the row that I click, it returns the values โโof that row. How do I do that?
This discussion has been closed.
Replies
Here is an example of buttons in the row:
http://live.datatables.net/xijecupo/1/edit
Kevin
I already have the buttons in the table, I need that according to the row that I touch to return the information of the row. How do I go through all the rows?
The example shows how to get the row data of the clicked button. The key is to get the
tr
of the clicked row usingvar row = $(this).closest('tr');
then usingvar data = table.row( row ).data()
to get the data for the row. If this doesn't help please post a link to your page or a running test case showing what you have so we can help.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Not sure what you are asking for but to iterate all the rows use
rows().every()
.Kevin
I did something like that, but it returns all the items I have. I want it to return the elements of the row that I click, in the row there are 5 elements and I want it to return 3 (integer, decimal, natural)
Maybe I don't understand. I have posted an example and code snippets of how to get the row data form the clicked row. Are you looking for something different?
Please provide a test case of what you have. Maybe it will help my understanding of your question.
Kevin
ok
I can't show you the code
Hmm, that will make it difficult to help. You can't build a simple example, maybe update mine, to show what you have for the buttons?
Kevin
It doesn't matter, thanks anyway, I can send it to you by private message if possible
alright I'll look.
Kevin
I send you a private message
Took a look. You are invoking a modal via the button using
data-toggle='modal' data-target='#modalWindow'
on thebutton
tag. You are using this modal event$("#modalWindow, body").on("shown.bs.modal", function () {
. In the event we need to get the clicked element. This SO thread has some examples of how to do this.Using this will give you the row data:
Kevin
Thanks !!