How to send hidden value by row

How to send hidden value by row

chiraggarg2906chiraggarg2906 Posts: 4Questions: 0Answers: 0

"I want to be able to select any row, so please add a checkbox and include the ID in a hidden field. I tried using <th data-visible="false"></th>, but it's not working. How can I achieve this?"

Replies

  • kthorngrenkthorngren Posts: 22,159Questions: 26Answers: 5,100

    Are you asking how to hide a column? Use columns.visible and set it false.

    Kevin

  • chiraggarg2906chiraggarg2906 Posts: 4Questions: 0Answers: 0

    Thanks.
    But when I use visible: false, I'm not able to get the value.

    This is the current HTML element when I use:
    columnDefs: [
    { targets: 1, visible: false }
    ]

    <td class="no-wrap"></td>

    Previously (when I was using DataTables version 1.6.0), the HTML looked like this:

    <td class="hidden no-wrap">
    <input type="checkbox" name="asset_id" id="asset_9329" value="9329" class="checkbox">
    </td>

    If you’d like, I can help you troubleshoot why the checkbox is missing when using visible: false. Let me know!

  • kthorngrenkthorngren Posts: 22,159Questions: 26Answers: 5,100

    But when I use visible: false, I'm not able to get the value.

    How are you trying to get the value?

    They won't be in the document so jQuery and Javascript methods won't find them.

    Use Datatables API's like cell().data() or cell().node() to access the hidden cells.

    For more specific help please provide a simple test case showing what you have.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Maybe start with this:
    https://live.datatables.net/

    Kevin

  • kthorngrenkthorngren Posts: 22,159Questions: 26Answers: 5,100

    Maybe this example of delegated events will help.

    Kevin

  • chiraggarg2906chiraggarg2906 Posts: 4Questions: 0Answers: 0

    Thanks for the suggestion!
    Can I get the checked value of the selected row?

  • chiraggarg2906chiraggarg2906 Posts: 4Questions: 0Answers: 0

    can i add hidden checkbox in row ??

  • allanallan Posts: 64,743Questions: 1Answers: 10,713 Site admin

    can i add hidden checkbox in row ??

    Sure. Add a class or style to it and set it to display: none.

    Can I get the checked value of the selected row?

    Selected how - via Select, or via one of your own methods? For Select, use the API.

    Allan

Sign In or Register to comment.