2014-10-15 2 views
0

'ReportItemCategoryID'를 기반으로 두 개의 별도 열을 만드는 페이지가 있습니다. ! = 8이면 왼쪽 열에 표시됩니다. == 8이면 오른쪽 열에 표시됩니다. 두 개의 열 서식이 작동하지만 나는 알아낼 수없는 문제에 직면 해 있습니다. 왼쪽 열 ("col1")에 있어야하고 오른쪽 열 ("col2")에 있어야하는 1 개의 콘텐츠 5 개가 있습니다. foreach 루프가 실행되면 div ID가 올바르게 나열됩니다 (5 개는 "col1"이고 1 개는 "col2"를 가짐). 첫 번째 foreach 루프를 통해 오는 범주 중 4 개가 두 번째 열에 나타나고 첫 번째 열에 나타나지 않는 이유는 누구에게 설명 할 수 있습니까? 2 열 페이지의 내용이 올바르지 않습니다.

는 HTML

은 "span6"클래스가 콘텐츠에 대한 폭을 선언합니다. "pull-left"클래스는 내용을 부동 소수점 형식으로 형식화합니다.

<div class="row-fluid"> 
     @foreach (var group in Model.Where(i => i.Active && i.ReportItemCategory.Active && i.Visible && i.ReportItemCategoryID!=8).GroupBy(i => i.ReportItemCategoryID).OrderBy(i => i.FirstOrDefault().ReportItemCategory.Name)) 
{ 
     <div id="col1" class="span6 pull-left"> 
      <ul class="nav nav-list"> 
       <li class="nav-header"> 
        <div class="input-append"> 

         <div rel="tooltip" title="@group.First().ReportItemCategory.Description"> 
          <img src="@Url.Content("~/img/folder-horizontal.png")" alt="Folder" style="margin-bottom:-3px;"/> 
          <span>@group.FirstOrDefault().ReportItemCategory.Name</span> 
         </div> 

         <ul class="nav nav-list"> 
          @foreach (var item in group.OrderBy(i => i.Name)) 
          { 
           <li> 
            <div class="input-append" rel="tooltip" title="@item.Description"> 
             <img src="@Url.Content("~/img/chart.png")" alt="Report" style="margin-bottom:-3px;"/> 
             <a href="#" onclick="javascript:newPopup('@Url.Action("ViewReport", "Reporting", new { id = item.ReportItemID })');return false;">@item.Name</a> 
            </div> 
           </li> 
          } 
         </ul> 
        </div> 
       </li> 
      </ul> 
     </div> 

} 
@foreach (var group in Model.Where(i => i.Active && i.ReportItemCategory.Active && i.Visible && i.ReportItemCategoryID==8).GroupBy(i => i.ReportItemCategoryID).OrderBy(i => i.FirstOrDefault().ReportItemCategory.Name)) 
{ 
     <div id="col2" class="span6 pull-left"> 
      <ul class="nav nav-list"> 
       <li class="nav-header"> 
        <div class="input-append"> 

         <div rel="tooltip" title="@group.First().ReportItemCategory.Description"> 
          <img src="@Url.Content("~/img/folder-horizontal.png")" alt="Folder" style="margin-bottom:-3px;"/> 
          <span>@group.FirstOrDefault().ReportItemCategory.Name</span> 
         </div> 

         <ul class="nav nav-list"> 
          @foreach (var item in group.OrderBy(i => i.Name)) 
          { 
           <li> 
            <div class="input-append" rel="tooltip" title="@item.Description"> 
             <img src="@Url.Content("~/img/chart.png")" alt="Report" style="margin-bottom:-3px;"/> 
             <a href="#" onclick="javascript:newPopup('@Url.Action("ViewReport", "Reporting", new { id = item.ReportItemID })');return false;">@item.Name</a> 
            </div> 
           </li> 
          } 
         </ul> 
        </div> 
       </li> 
      </ul> 
     </div> 
} 
</div> 

결과는 COL 이전

+-------------------------------------+ 
|+---------------+ +---------------+| 
||    | |    || 
||    | |    || 
||    | +---------------+| 
||    | +---------------+| 
||    | |    || 
||    | |    || 
||    | +---------------+| 
||    | +---------------+| 
||    | |    || 
||    | |    || 
||    | +---------------+| 
||    | +---------------+| 
|+---------------+ |    || 
|     |    || 
|     +---------------+| 
|     +---------------+| 
|     |    || 
|     |    || 
|     +---------------+| 
|          | 
|          | 
+-------------------------------------+ 

답변

0

를 확장하지

+-------------------------------------+ 
|+---------------+ +---------------+| 
||    | |    || 
||    | |    || 
||    | +---------------+| 
||    |     | 
|+---------------+     | 
|+---------------+     | 
||    |     | 
||    |     | 
|+---------------+     | 
|+---------------+     | 
||    |     | 
||    |     | 
|+---------------+     | 
|+---------------+     | 
||    |     | 
||    |     | 
|+---------------+     | 
|+---------------+     | 
||    |     | 
||    |     | 
|+---------------+     | 
+-------------------------------------+ 

실제 결과을 확장 할 수 없음 예상 1 및 col2 div foreach 루프 바깥 쪽. 이것은 각 foreach 루프가 해당 div 내에서 실행되었는지 확인했습니다. 이 같은 문제가있는 사람이있을 경우를 대비하여이 답변을 게시하고 있습니다.

<div class="row-fluid"> 
<div id="col1" class="span6 pull-left"> 
@foreach (var group in Model.Where(i => i.Active && i.ReportItemCategory.Active && i.Visible && i.ReportItemCategoryID!=8).GroupBy(i => i.ReportItemCategoryID).OrderBy(i => i.FirstOrDefault().ReportItemCategory.Name)) 
{ 

      <ul class="nav nav-list"> 
       <li class="nav-header"> 
        <div class="input-append"> 

         <div rel="tooltip" title="@group.First().ReportItemCategory.Description"> 
          <img src="@Url.Content("~/img/folder-horizontal.png")" alt="Folder" style="margin-bottom:-3px;"/> 
          <span>@group.FirstOrDefault().ReportItemCategory.Name</span> 
         </div> 

         <ul class="nav nav-list"> 
          @foreach (var item in group.OrderBy(i => i.Name)) 
          { 
           <li> 
            <div class="input-append" rel="tooltip" title="@item.Description"> 
             <img src="@Url.Content("~/img/chart.png")" alt="Report" style="margin-bottom:-3px;"/> 
             <a href="#" onclick="javascript:newPopup('@Url.Action("ViewReport", "Reporting", new { id = item.ReportItemID })');return false;">@item.Name</a> 
            </div> 
           </li> 
          } 
         </ul> 
        </div> 
       </li> 
      </ul> 


} 
</div> 
<div id="col2" class="span6 pull-left"> 
@foreach (var group in Model.Where(i => i.Active && i.ReportItemCategory.Active && i.Visible && i.ReportItemCategoryID==8).GroupBy(i => i.ReportItemCategoryID).OrderBy(i => i.FirstOrDefault().ReportItemCategory.Name)) 
{ 

      <ul class="nav nav-list"> 
       <li class="nav-header"> 
        <div class="input-append"> 

         <div rel="tooltip" title="@group.First().ReportItemCategory.Description"> 
          <img src="@Url.Content("~/img/folder-horizontal.png")" alt="Folder" style="margin-bottom:-3px;"/> 
          <span>@group.FirstOrDefault().ReportItemCategory.Name</span> 
         </div> 

         <ul class="nav nav-list"> 
          @foreach (var item in group.OrderBy(i => i.Name)) 
          { 
           <li> 
            <div class="input-append" rel="tooltip" title="@item.Description"> 
             <img src="@Url.Content("~/img/chart.png")" alt="Report" style="margin-bottom:-3px;"/> 
             <a href="#" onclick="javascript:newPopup('@Url.Action("ViewReport", "Reporting", new { id = item.ReportItemID })');return false;">@item.Name</a> 
            </div> 
           </li> 
          } 
         </ul> 
        </div> 
       </li> 
      </ul> 

} 
</div> 
</div> 
관련 문제