1
이것은 일반적인 html 테이블의 모습입니다. 표에서 국가를 탭으로 표시하고 사용자가 클릭하는 모든 탭에서 표는 특정 국가 (탭)에 속한 팀을 표시합니다. 이것은 잘 작동합니다.데이터 테이블에 항목 표시
<div class="nav-tabs-custom" id="tabs">
<ul id="myUL" class="nav nav-tabs">
@foreach($countries as $country)
<li ><a href="#tab_{{ $country->id }}" data-toggle="tab" >{!!$country->name!!}</a></li>
@endforeach
</ul>
<div class="tab-content">
@foreach($countries as $key => $country)
<div class="tab-pane" id="tab_{{ $country->id }}">
<table class="table" id="tables">
<thead>
<tr>
<th></th>
<th colspan="5"></th>
<th></th>
</tr>
</thead>
<tbody id="list">
@foreach($country->teams as $team)
<td><input onclick="return show(this)" data-team="{{$team->toJson()}}" type="checkbox" id="{!! $team->id !!}" name="{!! $team->name !!}" value="{!! $team->value !!}" /> </td>
<td width="600">{{$team->name }}</td>
<td>{{ $team->value}}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endforeach
</div>
</div>
그러나 지금, 나는 datatables 새로운 오전 그리고 난
이public function create()
{
$countries = Country::where('id', Auth::user()->id)->get();
return view('create',compact('countries'));
}
public function getTeams()
{
$countries = Country::where('id', Auth::user()->id)->get();
return Datatables::of($countries)->addColumn('check', function ($country) {
foreach($country->teams as $team){
return '
<input onclick="return show(this)" data-team="{{$team->toJson()}}" type="checkbox" id="{!! $team->id !!}" name="{!! $team->name !!}" value="{!! $team->value !!}" />
';
}
})->addColumn('team_name', function ($country) {
foreach($country->teams as $team){
return $team->name;
}
})->addColumn('team_value', function ($country) {
foreach($country->teams as $team){
return $team->value;
}
})
->make(true);
}
이제 내 문제는
<div class="nav-tabs-custom" id="tabs">
<ul id="myUL" class="nav nav-tabs">
@foreach($countries as $country)
<li ><a href="#tab_{{ $country->id }}" data-toggle="tab" >{!!$country->name!!}</a></li>
@endforeach
</ul>
<div class="tab-content">
@foreach($countries as $key => $country)
<div class="tab-pane" id="tab_{{ $country->id }}">
<table class="table" id="tables">
<thead>
<tr>
<th></th>
<th colspan="5"></th>
<th></th>
</tr>
</thead>
</table>
</div>
@endforeach
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
oTable = $('#tables').DataTable({
"processing": true,
"serverSide": true,
"bProcessing":false,
"bSort":false,
"ajax": "{{ route('datatable.findteam') }}",
"columns": [
{data: 'check', name: 'check', orderable: false, searchable: false},
{data: 'team_name', name: 'team_name'},
{data: 'team_value', name: 'team_value'},
],
});
});
</script>
아래 컨트롤러로 datatables에 html로 변환하려고 내 프로젝트를 실행하면 로그인 한 사용자의 팀을 표시 할 수 있지만 팀을 해당 국가로 분류 할 수는 없습니다.
PS : 당신이 작동하는 일반 HTML 테이블에 보면, 당신은 내가 탭의 컨텐츠 실제로
@ davidkonrad, 당신과 비슷하게 보일지 모르지만, 이전 질문으로가는 길을 찾았 기 때문에 제기 된 또 다른 질문입니다. – XamarinDevil
을 원할 경우 읽고 싶을 수도 있습니다. 수축되었습니다. 그러나 그들은 끔찍하게 비슷해 보였으며 질문이 게시 된 후 유예 기간의 맨 아래에있는 질문 텍스트의 일부만 변경했습니다. 우리는 계속해서 "내 일을하라"는 질문을 많이 보았 기 때문에 나는 이런 종류의 질문을 정말로 알고있다. 사람들은 할당 된 작업을 가지고 있으며,이 작업을 해결하는 모든 부분은 질문으로 단계적으로 생성됩니다 ... – davidkonrad
테이블'# tables'의 ID를 확인하십시오. foreach 루프에서 생성되기 때문에 동일한 id를 여러 번 재사용한다고 가정합니다. 문제의 일부가 될 수 있습니다. – dbrumann