title: How do I use datatable child row without ajax?
body: <p>I'm using the datatable example of child rows without the ajax and im having a problem where my child rows all have the same data. I want to show the data of each row in the child table but its giving me error when I use the laravel code in the function format section. I am using laravel MVC format so I don't need ajax to load data.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    
  function format ( d ) {
      // `d` is the original data object for the row
      return '&lt;div class="col-md-8" style="padding-top:20px;"&gt;'+
          '&lt;table class="table table-bordered"&gt;'+
              '&lt;tr&gt;'+
                  '&lt;th&gt;'+
                      "Product Name"+
                  '&lt;/th&gt;'+
                  '&lt;th&gt;'+
                      "Quantity"+
                  '&lt;/th&gt;'+
              '&lt;/tr&gt;'+                
              '&lt;tr&gt;'+
                  '&lt;td&gt;'+
                      "Item id here"+
                  '&lt;/td&gt;'+
                  '&lt;td&gt;'+
                      "Item data here"+
                  '&lt;/td&gt;'+
              '&lt;/tr&gt;'+
          '&lt;/table&gt;'+
      '&lt;/div&gt;';
  }
  
  $('#manageOrderTable tbody button').on('click', function () {
      var tr = $(this).closest('tr');
      var row = t.row( tr );
  
      if ( row.child.isShown() ) {
          // This row is already open - close it
          row.child.hide();
          tr.removeClass('shown');
      }
      else {
          // Open this row
          row.child( format(row.data()) ).show();
          tr.addClass('shown');
      }
  } );</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;tbody&gt;
      @php 
      $x=0; 
      @endphp
      @foreach ($orders as $order)                                  
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;{{$order-&gt;order_date}}&lt;/td&gt;
          &lt;td&gt;{{$order-&gt;client_name}}&lt;/td&gt;
          &lt;td&gt;{{$order-&gt;client_contact}}&lt;/td&gt;
          &lt;td class="details-control"&gt;
              &lt;button class="btn btn-info btn-xs"&gt;
                  &lt;b&gt;Items : &lt;/b&gt; {{$item_count["$x"]}} 
              &lt;/button&gt;
              Item Id: @for ($y = 0; $y &lt; $item_count["$x"]; $y++)
                      {{$item_list["$y"]-&gt;product_id}}
                  @endfor      
          &lt;/td&gt;
          @if ($order-&gt;payment_status==1)
          &lt;td&gt;&lt;label class="label label-success"&gt;Full Payment&lt;/label&gt;&lt;/td&gt;
          @elseif($order-&gt;payment_status==2)
          &lt;td&gt;&lt;label class="label label-info"&gt;Advance Payment&lt;/label&gt;&lt;/td&gt;
          @else
          &lt;td&gt;&lt;label class="label label-warning"&gt;No Payment&lt;/label&gt;&lt;/td&gt;
          @endif
          &lt;td&gt;
              &lt;!-- Single button --&gt;
              &lt;div class="btn-group"&gt;
                &lt;button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"&gt;
                  Action &lt;span class="caret"&gt;&lt;/span&gt;
                &lt;/button&gt;
                &lt;ul class="dropdown-menu"&gt;
                  &lt;li&gt;&lt;a href="{{route('orders.edit',$order-&gt;order_id)}}" id="editOrderModalBtn"&gt; &lt;i class="glyphicon glyphicon-edit"&gt;&lt;/i&gt; Edit&lt;/a&gt;&lt;/li&gt;
                  
                  &lt;li&gt;&lt;a type="button" data-toggle="modal" id="paymentOrderModalBtn" data-target="#paymentOrderModal" data-due="{{$order-&gt;due}}" data-id="{{$order-&gt;order_id}}"&gt; &lt;i class="glyphicon glyphicon-save"&gt;&lt;/i&gt; Payment&lt;/a&gt;&lt;/li&gt;
  
                  &lt;li&gt;&lt;a type="button" onclick="printOrder({{$order-&gt;order_id}})"&gt; &lt;i class="glyphicon glyphicon-print"&gt;&lt;/i&gt; Print &lt;/a&gt;&lt;/li&gt;
                  
                  
                  &lt;li&gt;&lt;a href="{{route('orderDelete',$order-&gt;order_id)}}" type="button"&gt; &lt;i class="glyphicon glyphicon-trash"&gt;&lt;/i&gt; Remove&lt;/a&gt;&lt;/li&gt;       
                &lt;/ul&gt;
              &lt;/div&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
      @php
      $x++;
      @endphp
      @endforeach
  &lt;/tbody&gt;</code></pre>
  </div>
  </div>
  </p>