2015-04-20 30 views
0

我在我的頁面中有一個CheckBoxList,裏面有28個ListItems。當我把RepeatColumns =「2」時,我的CheckBoxList被分成14個項目的兩列。我想要做的是製作17個物品的第一列,而第二個包含剩餘的11個物品。如何修改我的代碼以顯示CheckBoxList中的不均列?如何在每列中使用不同數量的項目製作CheckBoxList?

<asp:CheckBoxList ID="rblPraticasTemasSaude" runat="server" RepeatDirection="Vertical" RepeatColumns="2"> 
     <asp:ListItem Text="01" Value="01"></asp:ListItem> 
     <asp:ListItem Text="02" Value="02"></asp:ListItem> 
     <asp:ListItem Text="03" Value="03"></asp:ListItem> 
<%-- more ListItems --%> 
     <asp:ListItem Text="27" Value="27"></asp:ListItem> 
     <asp:ListItem Text="28" Value="28"></asp:ListItem> 
    </asp:CheckBoxList> 

回答

0

設置你的RepeatColumns屬性爲17,然後用這個功能

function rotate() { 
      $("#<%= rblPraticasTemasSaude.ClientID %>").each(function() { 
       var $this = $(this); 
       var newrows = []; 
       $this.find("tr").each(function() { 
        var i = 0; 
        $(this).find("td").each(function() { 
         i++; 
         if (newrows[i] === undefined) { newrows[i] = $("<tr></tr>"); } 
         newrows[i].append($(this)); 
        }); 
       }); 
       $this.find("tr").remove(); 
       $.each(newrows, function() { 
        $this.append(this); 
       }); 
      }); 
      return false; 
     } 

     rotate(); 

您需要rotate功能

+0

您的解決方案完全工作之前引用的jQuery。之後,我只需將RepeatDirection屬性從「Vertical」更改爲「Horizo​​ntal」,然後按我需要的方式排列我的CheckBoxList。謝謝。 –

+0

我很高興聽到這個消息 –

相關問題