Laravel Datatables - Subtable implement

Hello!

I would like to implement a datatable from HTML version ( with subtable ) in Laravel version using Yajra Laravel described here:

https://preview.keenthemes.com/metronic8/laravel/documentation/general/datatables/overview?demo=demo1

This is the table: https://preview.keenthemes.com/html/metronic/docs/general/datatables/subtable

Everything is working just fine, but I need some help in adding the row for the subtable to the actual table at initialization. I basically need to add this code to the table and don't know how:

<!--begin::SubTable template-->
<tr data-kt-docs-datatable-subtable="subtable_template" class="d-none">
<td colspan="2">
<div class="d-flex align-items-center gap-3">
<a href="#" class="symbol symbol-50px bg-secondary bg-opacity-25 rounded">
<img src="/assets/media/stock/ecommerce/" alt="" data-kt-docs-datatable-subtable="template_image" />
</a>
<div class="d-flex flex-column text-muted">
<a href="#" class="text-dark text-hover-primary fw-bold" data-kt-docs-datatable-subtable="template_name">Product name</a>
<div class="fs-7" data-kt-docs-datatable-subtable="template_description">Product description</div>
</div>
</div>
</td>
<td class="text-end">
<div class="text-dark fs-7">Cost</div>
<div class="text-muted fs-7 fw-bold" data-kt-docs-datatable-subtable="template_cost">1</div>
</td>
<td class="text-end">
<div class="text-dark fs-7">Qty</div>
<div class="text-muted fs-7 fw-bold" data-kt-docs-datatable-subtable="template_qty">1</div>
</td>
<td class="text-end">
<div class="text-dark fs-7">Total</div>
<div class="text-muted fs-7 fw-bold" data-kt-docs-datatable-subtable="template_total">name</div>
</td>
<td class="text-end">
<div class="text-dark fs-7 me-3">On hand</div>
<div class="text-muted fs-7 fw-bold" data-kt-docs-datatable-subtable="template_stock">32</div>
</td>
<td></td>
</tr>
<!--end::SubTable template-->

Thank you!

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi Dumitrescu Daniel

Instead of adding a table row as HTML codes, you can add it via the data. Append a new data row and then reload the table.

You can do it using js.
https://datatables.net/examples/api/add_row.html

Or append the data in the query() function in the datatable initialization file.

Thanks

Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Here's a how to add some HTML formatting to your comment:
  • <pre></pre> for JS codes block
  • <pre lang="html"></pre> for HTML code block
  • <pre lang="scss"></pre> for SCSS code block
  • <pre lang="php"></pre> for PHP code block
  • <code></code> for single line of code
  • <strong></strong> to make things bold
  • <em></em> to emphasize
  • <ul><li></li></ul>  to make list
  • <ol><li></li></ol>  to make ordered list
  • <h3></h3> to make headings
  • <a></a> for links
  • <img> to paste in an image
  • <blockquote></blockquote> to quote somebody
  • happy  :)
  • shocked  :|
  • sad  :(