How to get input values inside of a column?

How to get input values inside of a column?

renankaicrenankaic Posts: 1Questions: 1Answers: 0

Hello. First, I would like to ask to anyone who read this thread to read this before:
https://stackoverflow.com/questions/53228186/jquery-datatables-cant-get-input-value-from-hidden-pages

Right. One of users suggested to use the data table API to get the values from the inputs who are hidden in the tbody because they doesn't stay in the DOM if I change the selected page.

But, how could I do that?

How can I get the last column and it's contents and transfer to a javascript code and get the input values?

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947
    edited November 2018

    Datatables contains it's own data cache separate from the table in the DOM. When using DOM based inputs: To use the Datatables API's to get the data you will first need to update the cache using one of the following invalidate methods. Which one depends on your specific situation.

    Each time the input field is updated you will need to use one of the above to update the Datatables data cache.

    You will use one of the following to get the data.

    When you look a the docs for cell(), row() and their plural versions you will see links to pages that describe the selectors and modifiers you can use to choose which cell(s) or row(s) you want.

    This is a general answer. If you provide specifics regarding your data structure, config, etc we can better help you. Maybe you can provide a test case showing what you are doing and we can help with your code to get the data.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    I had a few minutes to put a quick sample together.
    http://live.datatables.net/vuhehalo/1/edit

    There are many ways to do this but for this example the inputs are in column 1 (2nd column). The easiest way to see this work is to update the input in row 1 (Tiger Nixon) then go to page 2. Click the "Get Positions" button. Data for all rows in column 1 will be collected but only the first row (Tiger Nixon) will be displayed.

    Kevin

This discussion has been closed.