【问题标题】:jquery plugin - chosen - multiple selection not listing in a row but a columnjquery插件 - 选择 - 多项选择不是在一行中列出,而是在一列中
【发布时间】:2015-03-10 20:43:56
【问题描述】:

我正在尝试将我的 ListBox 配置为使用 jquery 插件,选择 1.4。

我从数据库中获取 ListBox 的值,并将每个项目添加到 ListBox 后面的代码中,效果很好:

 //Populate the Recipient ListBox 
 DataTable tdtRecipients = new DataTable();
 tstrXmlTableData = m_pagingClient.GetRecipientList(m_strUserID);
 tdtRecipients = ParseXML(tstrXmlTableData);

  // string tstrRecipientLst = string.Empty;
  foreach (DataRow row in tdtRecipients.Rows)
  {
       lstBoxTo.Items.Add(row["Name"].ToString());                      
   }

ListBox 的样式设置为长,并在需要时添加垂直滚动条。这是来自样式表:

 #lstBoxTo
{
    width: 620px;
    height: 40px;
    overflow: scroll;
}

控件在面板中设置:

 <asp:Panel ID="pnlTo" runat="server" CssClass="basicRow" ClientIDMode="Static">
     <asp:Label ID="lblTo" runat="server"  CssClass="labelText" Text="To: " 
                ClientIDMode="Static"></asp:Label>
     <asp:ListBox ID="lstBoxTo" runat="server" SelectionMode="Multiple"  
                ClientIDMode="Static" ></asp:ListBox>
     </asp:Panel>

这是使用和配置所选插件的 javascript:

<script type="text/javascript">
    $(window).load(function () {
      $("#lstBoxTo").data("placeholder", "Choose recipient(s)...").chosen();
    });
</script>

列表框显示的宽度不如样式表指示的宽度,但宽度仅与最长的选择一样宽。该列表采用项目符号格式,当您进行多项选择时,它们不是在一行中,而是在一个项目符号列中。占位符“选择收件人”未显示,但默认占位符“选择选项”。

我希望列表框在网站上显示为http://harvesthq.github.io/chosen/,用于多选。但我不知道要设置哪些选项或如何设置它们。

任何帮助将不胜感激。

谢谢。 更新 删除 ClientIDMode 属性并将 Height 和 width 添加到属性后,ListBox 可以正确显示。 但在演示中,ListBox 应以“选择收件人”开头,并在您键入时显示如下列表。该列表显示在列表框中。

【问题讨论】:

    标签: javascript jquery-plugins jquery-chosen


    【解决方案1】:

    我想通了... 我错过了选择的样式表。 添加:
    到我的 Site.Master 文件,它工作正常。

    希望这对像我这样的新手有所帮助!

    【讨论】:

      猜你喜欢
      • 2011-07-02
      • 1970-01-01
      • 2015-01-01
      • 1970-01-01
      • 2018-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多