2014-04-05 58 views
0

這應該在表格中的每一行的隱藏行中顯示附加信息。隱藏的表格行不顯示它應該在的位置

問題是,它不是在行本身下顯示,而是在表格上方顯示。 因此,如果我選擇第3行以查看其附加信息,隱藏行應顯示在其下方,而是顯示在所有行的頂部。

我猜我的表格結構有問題,但是我找不出什麼。

而這裏的JSFiddle

<link rel="stylesheet" type="text/css" href="http://drvic10k.github.io/bootstrap-sortable/Contents/bootstrap-sortable.css"> 
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
<script src="http://drvic10k.github.io/bootstrap-sortable/Scripts/bootstrap-sortable.js"></script> 
<script src="http://drvic10k.github.io/bootstrap-sortable/Scripts/moment.min.js"></script> 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script> 
<script type="text/javascript"> 

$(document).ready(function(){ 

    $(".slidingDiv").hide(); 
    $(".show_hide").show(); 

    $('.show_hide').click(function(){ 
    $(".slidingDiv").slideToggle(); 
}); 

}); 

</script> 

<div class="box"> 
    <div class="box-header"> 
     <h3 class="box-title">View Listings</h3> 
     <div class="box-tools"> 
      <div class="input-group"> 
       <input type="text" name="table_search" class="form-control input-sm pull-right" style="width: 150px;" placeholder="Search"> 
       <div class="input-group-btn"> 
        <button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button> 
       </div> 
      </div> 
     </div> 
    </div><!-- /.box-header --> 
    <div class="box-body table-responsive no-padding"> 
      <table class="table table-hover table-striped sortable" style="border-collapse:collapse;"> 
       <thead> 
        <tr> 
         <th data-defaultsort="asc" data-sortcolumn="0" data-sortkey="0-1">ID</th> 
         <th data-defaultsign="month" data-sortcolumn="1" data-sortkey="1-1">Status</th> 
         <th data-sortcolumn="2" data-sortkey="2-1">For</th> 
         <th data-sortcolumn="3" data-sortkey="3-1">Availability</th> 
         <th data-mainsort="true" data-sortcolumn="4" data-sortkey="4-1">Type<span class="sign arrow"></span></th> 
         <th data-sortcolumn="5" data-sortkey="5-1">Contact</th> 
         <th data-sortcolumn="6" data-sortkey="6-1">Reference ID</th> 
         <th data-sortcolumn="7" data-sortkey="7-1">Location</th> 
         <th data-sortcolumn="8" data-sortkey="8-1">Category</th> 
         <th data-sortcolumn="9" data-sortkey="9-1">Apartment Area</th> 
         <th data-sortcolumn="10" data-sortkey="10-1">Garden Area</th> 
         <th data-sortcolumn="11" data-sortkey="11-1">Parking</th> 
         <th data-sortcolumn="12" data-sortkey="12-1">Visitors Parking</th> 
         <th>Action</th> 
        </tr> 
       </thead> 
       <tbody> 
       @foreach($listings as $key => $value) 
       <tr data-toggle="collapse" data-target="#{{ $value->id }}" class="accordion-toggle"> 
        <td data-value="{{ $value->id }}">{{ $value->id }}</td> 
        <td data-value="{{ $value->status }}">{{ $value->status }}</td> 
        <td data-value="{{ $value->listingfor }}">{{ $value->listingfor }}</td> 
        <td data-value="{{ $value->propertystatus }}">{{ $value->propertystatus }}</td> 
        <td data-value="{{ $value->propertytype }}">{{ $value->propertytype }}</td> 
        <td data-value="{{ $value->contact_id }}">{{ $value->contact_id }}</td> 
        <td data-value="{{ $value->reference_id }}">{{ $value->reference_id }}</td> 
        <td data-value="{{ $value->location }}">{{ $value->location }}</td> 
        <td data-value="{{ $value->category }}">{{ $value->category }}</td> 
        <td data-value="{{ $value->apartment_area }}">{{ $value->apartment_area }}</td> 
        <td data-value="{{ $value->garden_area }}">{{ $value->garden_area }}</td> 
        <td data-value="{{ $value->parking }}">{{ $value->parking }}</td> 
        <td data-value="{{ $value->visitors_parking }}">{{ $value->visitors_parking }}</td> 
        <td><a class="btn btn-small btn-success" href="{{ URL::to('listings/view/' . $value->id) }}">Show</a> <a class="btn btn-small btn-info" href="{{ URL::to('listings/view/' . $value->id . '/edit') }}">Edit</a> <a class="btn btn-small btn-danger" href="{{ URL::to('listings/view/' . $value->id . '/delete') }}">Delete</a></td> 
        <tr> 
         <td colspan="14" class="hiddenRow"> 
         <div class="accordian-body collapse" id="{{ $value->id }}"> 
         <p>Lifestyle: {{ $value->lifestyle }}</p> 
         </div> 
         </td> 
        </tr> 
       </tr> 
       @endforeach 
       </tbody> 
      </table> 
    </div><!-- /.box-body --> 
</div> 
+0

我試着清理一下你的縮進。這可以讓你更容易地看到你放入了一個額外的結尾''標籤,與@baeda所說的幾乎相反。 – trysis

+0

您在頂部使用4個空格/製表符縮進,但之後切換到2。我不知道該走哪條路,但我試着用2.如果你不喜歡它,我可以改爲4. – trysis

+0

對不起,我的意思是@baeda說的。然而,他把桌子放在排內,這使得這一切都令人困惑,並且Inception-y。 – trysis

回答

0

你忘了啓動新行之前關閉您的<TR>標籤。

@foreach($listings as $key => $value) 
<tr data-toggle="collapse" data-target="#{{ $value->id }}" class="accordion-toggle"> 
    <td> 
     <table> 
      <tr> 
       <td data-value="{{ $value->id }}">{{ $value->id }}</td> 
       <td data-value="{{ $value->status }}">{{ $value->status }}</td> 
       <td data-value="{{ $value->listingfor }}">{{ $value->listingfor }}</td> 
       <td data-value="{{ $value->propertystatus }}">{{ $value->propertystatus }}</td> 
       <td data-value="{{ $value->propertytype }}">{{ $value->propertytype }}</td> 
       <td data-value="{{ $value->contact_id }}">{{ $value->contact_id }}</td> 
       <td data-value="{{ $value->reference_id }}">{{ $value->reference_id }}</td> 
       <td data-value="{{ $value->location }}">{{ $value->location }}</td> 
       <td data-value="{{ $value->category }}">{{ $value->category }}</td> 
       <td data-value="{{ $value->apartment_area }}">{{ $value->apartment_area }}</td> 
       <td data-value="{{ $value->garden_area }}">{{ $value->garden_area }}</td> 
       <td data-value="{{ $value->parking }}">{{ $value->parking }}</td> 
       <td data-value="{{ $value->visitors_parking }}">{{ $value->visitors_parking }}</td> 
       <td><a class="btn btn-small btn-success" href="{{ URL::to('listings/view/' . $value->id) }}">Show</a> <a 
         class="btn btn-small btn-info" href="{{ URL::to('listings/view/' . $value->id . '/edit') }}">Edit</a> 
        <a 
         class="btn btn-small btn-danger" 
         href="{{ URL::to('listings/view/' . $value->id . '/delete') }}">Delete</a> 
       </td> 
      </tr> 
      <tr> 
       <th colspan="14" class="hiddenRow"> 
        <div class="accordian-body collapse" id="{{ $value->id }}"> 
         <p>Lifestyle: {{ $value->lifestyle }}</p> 
        </div> 
       </th> 
      </tr> 
     </table> 
    </td> 
</tr> 
@endforeach 
+0

這並沒有解決問題。隱藏的行仍在頂部顯示。我並沒有忘記關閉標籤,而是將其作爲內的,但這顯然不起作用。 – Halnex

+0

標籤內不能有。如果你想摺疊所有東西(包括隱藏的行),你需要在你的數據開關中有一張表。我編輯了我的帖子。 – baeda

+0

這沒有奏效。順便提一下,我已經有了一張桌子。我編輯了我的帖子。 – Halnex

0

它看起來像你試圖在你的最後一個單元格內保持你的隱藏行。但是,在你做出內部行之前,你關閉了單元格。你的代碼很混亂,所以我不確定是否是這種情況,但這就是它的樣子。

<table class="table table-hover table-striped sortable" style="border-collapse:collapse;"> 
    <thead> 
     <tr> 
      <th data-defaultsort="asc" data-sortcolumn="0" data-sortkey="0-1">ID</th> 
      <th data-defaultsign="month" data-sortcolumn="1" data-sortkey="1-1">Status</th> 
      <th data-sortcolumn="2" data-sortkey="2-1">For</th> 
      <th data-sortcolumn="3" data-sortkey="3-1">Availability</th> 
      <th data-mainsort="true" data-sortcolumn="4" data-sortkey="4-1">Type<span class="sign arrow"></span></th> 
      <th data-sortcolumn="5" data-sortkey="5-1">Contact</th> 
      <th data-sortcolumn="6" data-sortkey="6-1">Reference ID</th> 
      <th data-sortcolumn="7" data-sortkey="7-1">Location</th> 
      <th data-sortcolumn="8" data-sortkey="8-1">Category</th> 
      <th data-sortcolumn="9" data-sortkey="9-1">Apartment Area</th> 
      <th data-sortcolumn="10" data-sortkey="10-1">Garden Area</th> 
      <th data-sortcolumn="11" data-sortkey="11-1">Parking</th> 
      <th data-sortcolumn="12" data-sortkey="12-1">Visitors Parking</th> 
      <th>Action</th> 
     </tr> 
    </thead> 
    <tbody> 
     @foreach($listings as $key => $value) 
     <tr data-toggle="collapse" data-target="#{{ $value->id }}" class="accordion-toggle"> 
      <td data-value="{{ $value->id }}">{{ $value->id }}</td> 
      <td data-value="{{ $value->status }}">{{ $value->status }}</td> 
      <td data-value="{{ $value->listingfor }}">{{ $value->listingfor }}</td> 
      <td data-value="{{ $value->propertystatus }}">{{ $value->propertystatus }}</td> 
      <td data-value="{{ $value->propertytype }}">{{ $value->propertytype }}</td> 
      <td data-value="{{ $value->contact_id }}">{{ $value->contact_id }}</td> 
      <td data-value="{{ $value->reference_id }}">{{ $value->reference_id }}</td> 
      <td data-value="{{ $value->location }}">{{ $value->location }}</td> 
      <td data-value="{{ $value->category }}">{{ $value->category }}</td> 
      <td data-value="{{ $value->apartment_area }}">{{ $value->apartment_area }}</td> 
      <td data-value="{{ $value->garden_area }}">{{ $value->garden_area }}</td> 
      <td data-value="{{ $value->parking }}">{{ $value->parking }}</td> 
      <td data-value="{{ $value->visitors_parking }}">{{ $value->visitors_parking }}</td> 
      <td><a class="btn btn-small btn-success" href="{{ URL::to('listings/view/' . $value->id) }}">Show</a> <a class="btn btn-small btn-info" href="{{ URL::to('listings/view/' . $value->id . '/edit') }}">Edit</a> <a class="btn btn-small btn-danger" href="{{ URL::to('listings/view/' . $value->id . '/delete') }}">Delete</a> 
       <tr> 
        <td colspan="14" class="hiddenRow"> 
         <div class="accordian-body collapse" id="{{ $value->id }}"> 
          <p>Lifestyle: {{ $value->lifestyle }}</p> 
         </div> 
        </td> 
       </tr> 
      </td> 
     </tr> 
     @endforeach 
    </tbody> 
</table> 
+0

我在''中將''改爲'​​',現在隱藏的行顯示在表格的底部而不是頂部。我不得不使用''和'',因爲我使用插件添加排序到我的表格,它需要適當的表格格式,否則它將無法正常工作。 – Halnex

+0

那你是說我的答案有效嗎?對不起,但我不明白你的評論。 – trysis

+0

我很抱歉造成混亂,不是沒用。隱藏的行應該顯示在其父行下,而不是在整個表下。 – Halnex

相關問題