嗨我在我的视图中有这个表,但要求是我只需要显示9列,但数据库字段超过9.所以我做的是我做了一个下拉按钮,显示&#39 ;标志'我的数据库中的列是它的外观
在这里你可以看到我在悬停时已经添加了标志,它会显示特定记录的标志。但问题是,显示的值是一样的。这是我的代码
@foreach($myRep as $list)
<tr>
<td>{{ $list->reportid }}</td>
<td>{{ $list->reportname }}</td>
<td>{{ $list->username }}</td>
<td>{{ $list->filesize}}</td>
<td>{{ $list->filetype}}</td>
<td>
<a class='dropdown-button btn defcolor' href='#' data-activates='dropdown1'>Flags</a>
<ul id='dropdown1' class='dropdown-content dcont'>
<li>
VLR
@if($list->vlr == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->vlr == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
<li>
VOICE
@if($list->voiceservice == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->voiceservice == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
<li>
SMS
@if($list->smsservice == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->smsservice == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
<li>
DATA
@if($list->dataservice == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->dataservice == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
<li>
FINANCIALS
@if($list->financials == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->financials == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
<li>
DEVICES
@if($list->devices == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->devices == "false")
<i class="material-icons cRed">close</i>
@endif
</li>
</ul>
</td>
<td>{{ $list->doc_class }}</td>
<td>
@if($list->confidential == "true")
<i class="material-icons cGreen">check</i>
@elseif($list->confidential == "false")
<i class="material-icons cRed">close</i>
@endif
</td>
<td>{{ \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $list->created_at)->format('M - d - Y') }}</td>
</tr>
@endforeach
关于我做错什么的任何想法?非常感谢!
答案 0 :(得分:1)
我猜你的列表正在正确构建,但是你的javascript工作不正常并且一遍又一遍地显示相同的列表。
您需要确保您的元素具有唯一标识:
<a class='dropdown-button btn defcolor' href='#' data-activates='dropdown-{{ $list->reportid }}'>Flags</a>
<ul id='dropdown-{{ $list->reportid }}' class='dropdown-content dcont'>
现在你的javascript将知道它需要显示哪个列表。