Column visible: false

Column visible: false

Artur2024Artur2024 Posts: 3Questions: 1Answers: 0

The column "visible: false" is not hidden, but removed. Is it possible to have a column that is not visible? I would like to have a field "id" in the table that is not visible, but which I can read after clicking on the row.

Answers

  • Artur2024Artur2024 Posts: 3Questions: 1Answers: 0
    edited November 22

    Ok, I can read from data1[row][0], but what if data1 is no longer available?

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    data1[row][0]

    I'm not sure what data1 is?

    but what if data1 is no longer available?

    What is happening to make it not available?

    The Datatables API's, like row().data(), can access the data from columns hidden using columns.visible. They aren't in the document so jQuery and Javascript methods won't have access to them.

    This example shows how to get the row data of the clicked row. If this doesn't help then please post the code you are using or better a test case showing the issue you are having.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • Artur2024Artur2024 Posts: 3Questions: 1Answers: 0

    Thanks for your answer.

    Sorry, data1 is:

    const data1 = [
    ['Tiger Nixon', 'System Architect', '$3.120', 'Edinburgh' ],
    ["Garrett Winters", "Director", "$5,300", "Edinburgh" ],
    ];

    If:
    columns: [
    { name: 'first-name', visible: false },
    { name: 'last-name' },
    { name: 'position' },
    { name: 'location' }
    ]

    I can read this via data1[row][0]

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974

    Thanks for the clarification. Did you see the example I linked to earlier. It shows how to use row().data() to retrieve the data of the row clicked on. Does this technique not work for you?

    Kevin

Sign In or Register to comment.