Use data from other column as object attribute in another checkbox rendered column

Use data from other column as object attribute in another checkbox rendered column

aira.haira.h Posts: 2Questions: 1Answers: 0

I'm trying to access data from other column and attach it as object attribute in another rendered column.
In this case I have PstCode column and checkbox column. I want to add PstCode as id attribute in checkbox column

"columns": [
                   { "data": "PstCode" },
                   { "data": "PstText" },
                   {
                      "data": "checkbox",
                      render: function (data, type, row) {
                      if (type === 'display') {
                          return '<input type="checkbox" class="editor-active" id=([row.'PstCode']) onclick=Bindcb(this) name="cb">';}
                          return data;
                     }}]

Answers

  • aira.haira.h Posts: 2Questions: 1Answers: 0
    edited April 29

    I tried this code too but it is also didn't work

     return '<input type="checkbox" class="editor-active" id=' + row['PstCode'] + 'onclick=Bindcb(this) name="cb">';
    
  • colincolin Posts: 11,798Questions: 0Answers: 1,999

    On the first code, you've got a second return which would never be reached.

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.