Vue3 defaultContent how to add row data

Vue3 defaultContent how to add row data

jemzjemz Posts: 131Questions: 40Answers: 1
edited April 2023 in Free community support

Hi I am using Vue3

I want to access the row data to the defaultContent so that I can add the id from my database, Is this possible?


const columns = [ { data: 'firstname' }, { data: 'lastname' }, { data: null, className: "dt-center editor-edit", defaultContent: '<i class="fa fa-pencil"/>' <--- here I want to access the row data , orderable: false } ];

Thank you in advance

Replies

  • jemzjemz Posts: 131Questions: 40Answers: 1

    if not possible how can I get the id if I will click the button?

    Thank you in advance.

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    here I want to access the row data

    The row data is not accessible using columns.defaultContent. You can use columns.render to generate the button with info from the row.

    Or you can use a delegated event, like this example to get the row data of the clicked row. Not sure how this plays into Vue3 though :smile:

    Kevin

  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin

    Use row().data(). See this example.

    Allan

  • jemzjemz Posts: 131Questions: 40Answers: 1

    Thank you fixed now :)

Sign In or Register to comment.