How do I get the data of each row?

  • 0
    Hello everyone!

    There is a DataTables.

    Each line has input, select, textarea. I need to loop through each line and apply $ ('input, select, textarea'). Serialize (); to send it to the server for processing one by one.

    But nothing comes of it, I go around in a loop, but I get the data of the entire table for each row.

    My Code
    JavaScript Evangeline Webb, Apr 27, 2019

  • 1 Answers
  • 0
    The construction table.row (i). $ (...) looks dumb and behaves strangely. I don't remember such tricks in the documentation.

    const trElem = table.row(i).node(); // tr
    const $rowControls = $('input,select,textarea', trElem); // инпуты из строки
    const serialized = $rowControls.serialize();

    And for good reason, it would be necessary to send in one request, and not each line separately. Today there are a couple of dozen, and tomorrow 12,000.

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!