Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

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="#"%20class="symbol%20symbol-50px%20bg-secondary%20bg-opacity-25%20rounded" target="_blank" rel="noopener noreferrer">
<img src="/assets/media/stock/ecommerce/" alt="" data-kt-docs-datatable-subtable="template_image" />
</a>
<div class="d-flex flex-column text-muted">
Product name
<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
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • 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.


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

Thanks


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(