在现有表格中以编程方式添加行和列,而无需迁移 -laravel blade

问题描述 投票:0回答:1

有没有办法在现有的刀片表中增加行和列。我已经根据问题表和联系人使用 foreach 循环填充数据。我需要计算表中分数列的平均数、最小值和最大值,联系人和问题标签根据所选调查内容而有所不同。

    @php
     $FIXED_COLUMN_COUNT =5;
     $columnCount = $FIXED_COLUMN_COUNT + count($questionLabels);
     $rowCount = count($contacts) + 3;
    @endphp
   <div class="table-responsive">
        <table class="table table-bordered">
         <thead>
                <tr>
                    <th>#</th>
                    <th>Name</th>
                    <th>Email</th>
                     <th>StartDate</th>
                    <th>EndDate</th>
                    <th>Score</th>
                    @foreach($questionLabels as $questionLabel)
                      <th>{{ $questionLabel}}</th>
                    @endforeach
                </tr>
                </thead>
            <tbody>
                @foreach($contacts as $contact)
                 <tr><td></td></tr>
                 .
                 .
                 .
                 ..
                 .@foreach(answers as answer)
                 <tr><td></td></tr>
                 .
                 .
                 .
                 ..
                 @endforeach

                 Here i need max, min and average inside the table

                 </tbody>
                </table>
        </div

我想要这样的输出。在这里输入图像描述

php laravel view rows laravel-blade
1个回答
0
投票

像这种情况,我使用了jQuery,你必须导入 jQuery.js 然后试试这个

<script>
 $('#tableId tr:last').after('<tr>...</tr><tr>...</tr>');
</script>

<script>
 $('#tableId > tbody:last-child').append('<tr>...</tr><tr>...</tr>');
</script>
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.