title: How do I use data values as attribute values in datatables?
body: <p>I have this piece of code with its data in JSON ( converted from database) and I want the <strong>data-id</strong>  and <strong>id</strong> attributes value to come from the JSON data using <strong>JQuery DataTables</strong>.</p>
  
  <ol>
  <li>The code below works without errors but i want to replace the <code>data[0].id</code> with the iteration (something like <code>data[i].id</code>)</li>
  </ol>
  
  <p><strong>code</strong></p>
  
  <pre><code> $('#example_senderid').dataTable({
  
              data:  data,
              columns: [
              {'data':'user_id'},
              {'data':'name'},
              {'data':'status'},
              {'data':'date_added'},
              {'defaultContent':"&lt;button data-id='"+data[0].id+"' class='editConfirm'&gt;&lt;span class='fa fa-pencil'&gt;&lt;/span&gt;Edit&lt;/button&gt;"}
              ],
    'columnDefs': [
       {
          'targets':[1,2],
          'createdCell':  function (td,) {
             $(td).attr('id', 'editSenderConfirm'+data[0].id); 
          }
       }
    ]
  
  
            });
  </code></pre>
  
  <ol start="2">
  <li>I have tried point 1. but did not work.</li>
  </ol>
  
  <p>I am hoping there is a way to do it with the DataTable itself.
  Thanks in advance</p>