顯示具有 下拉選單 標籤的文章。 顯示所有文章
顯示具有 下拉選單 標籤的文章。 顯示所有文章

2024年5月9日 星期四

[研究]ASP.NET, 比較 select2, Selectize.js, Chosen, Bootstrap Select 下拉選單套件

[研究]ASP.NET, 比較 select2, Selectize.js, Chosen, Bootstrap Select 下拉選單套件

2024-05-06

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

ASP.NET, 請比較 select2, Selectize.js, Chosen, Bootstrap Select 特點 ? 優點 ? 缺點 ? 市佔率 (百分比) ? 用表格呈現 ?

ChatGPT

特點select2Selectize.jsChosenBootstrap Select
功能搜索、選項過濾、多選、AJAX 加載、主題自定義搜索、選項過濾、多選、創建新標籤、輕量級搜索、選項過濾、多選、默認主題美觀搜索、多選、與 Bootstrap 樣式相容
優點功能豐富、支援 AJAX 加載、主題自定義輕量、功能全面、支援創建新標籤美觀的默認主題、易於使用、與 Bootstrap 相容與 Bootstrap 樣式相容、易於使用
缺點樣式定製複雜、文件較大功能相對 select2 有限、樣式定製有限文件較大、功能相對有限功能相對有限、樣式定製有限
市佔率約 60%約 15%約 10%約 15%

********************************************************************************

Copilot

選項特點優點缺點市佔率
select2- 支持搜索和遠程數據源。
- 具有良好的自定義選項,例如主題、佈局和樣式。
- 強大的搜索功能,適用於大型數據集。- 需要引入 jQuery。
- 部分功能可能需要進一步自定義。
約 20%
Selectize.js- 允許用戶即時創建新選項。
- 可以選擇並刪除多個項目。
- 異步友好,支持回調。- 需要引入 Selectize.js 腳本。
- 部分功能可能需要進一步自定義。
受歡迎
Chosen- 基於 jQuery,易於使用。- 簡單易用,適合快速開發。
- 可以自定義樣式和佈局。
- 不支持異步數據源。
- 需要引入 jQuery。
不清楚
Bootstrap Select- 基於 Bootstrap,與 Bootstrap 样式一致。
- 支持搜索和多選。
- 與 Bootstrap 集成良好。- 需要引入 Bootstrap 和相關腳本。
- 部分功能可能需要進一步自定義。
約 10%


(完)

相關

[研究]Mend, Select2 與wicked-folders 2.18.4 和 pdf-poster-1.6.5 套件 GPT 或 MIT 授權疑問

[研究]Mend, Select2 與wicked-folders 2.18.4 和 pdf-poster-1.6.5 套件 GPT 或 MIT 授權疑問

2024-05-09

https://github.com/select2/select2/blob/develop/LICENSE.md

select2 是MIT授權

但 MEND 軟體說 select2使用的 wicked-folders 2.18.4 是 GPL-2.0
https://plugins.svn.wordpress.org/wicked-folders/tags/2.18.4/readme.txt

實際檢視 \Scripts\i18n\zh-TW.js 內容

用 Free Online Javascript Beautifier / Formatter 優化可讀性


/*! Select2 4.0.13 | https://github.com/select2/select2/blob/master/LICENSE.md */

! function () {
   if (jQuery && jQuery.fn && jQuery.fn.select2 && jQuery.fn.select2.amd) var n = jQuery.fn.select2.amd;
   n.define("select2/i18n/zh-TW", [], function () {
      return {
         inputTooLong: function (n) {
            return "請刪掉" + (n.input.length - n.maximum) + "個字元"
         },
         inputTooShort: function (n) {
            return "請再輸入" + (n.minimum - n.input.length) + "個字元"
         },
         loadingMore: function () {
            return "載入中…"
         },
         maximumSelected: function (n) {
            return "你只能選擇最多" + n.maximum + "項"
         },
         noResults: function () {
            return "沒有找到相符的項目"
         },
         searching: function () {
            return "搜尋中…"
         },
         removeAllItems: function () {
            return "刪除所有項目"
         }
      }
   }), n.define, n.require
}();

看不出哪裡使用  wicked-folders 2.18.4,不知是否誤判?

Mend 軟體說 \Scripts\i18n\zh-TW.js 是 wicked-folders-2.18.14 的,但是實際檢視

  • font-awesome/
  • select2/
  • sticky-kit/
不太清楚這是指  wicked-folders-2.18.14 販售給這3個套件?還是甚麼關係?

wicked-folders 有不同版本


********************************************************************************

MEND 報告 \Scripts\i18n\zh-TW.js 也使用 pdf-poster-1.6.5 套件,是 GPL-2.0,但看不出來。

(待續)

相關

[研究]ASP.NET,WebForm,試用 Bootstrap Select 1.13.18件,下拉選單關鍵字過濾顯示

[研究]ASP.NET,WebForm,試用 Bootstrap Select 1.13.18套件,下拉選單關鍵字過濾顯示

2024-05-06

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

https://github.com/selectize/selectize.js
授權 Apache-2.0


WebApplication1

正在安裝:

jQuery.1.9.1
bootstrap.3.0.0
bootstrap-select.1.13.18

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <%--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.3.3/css/bootstrap.min.css">--%>
    <%--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.6.2/css/bootstrap.min.css">--%>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.18/css/bootstrap-select.min.css">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <%--<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/5.3.3/js/bootstrap.bundle.min.js"></script>--%>
    <%--<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.6.2/js/bootstrap.bundle.min.js"></script>--%>
    <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.bundle.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.18/js/bootstrap-select.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.selectpicker').selectpicker();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
            <asp:DropDownList ID="DropDownList1" runat="server" CssClass="selectpicker" AutoPostBack="true">
                <asp:ListItem>Option 1</asp:ListItem>
                <asp:ListItem>Option 2</asp:ListItem>
                <asp:ListItem>Option 3</asp:ListItem>
            </asp:DropDownList>
    </form>
</body>
</html>


Bootstrap 5.3.3 和4.6.2 版測試有問題

Bootstrap 3.4.1 版測試有問題

********************************************************************************

Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs" Inherits="WebApplication1.Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta2/css/bootstrap-select.min.css">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.14.0-beta2/js/bootstrap-select.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.selectpicker').selectpicker();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <select id="ddlOptions" class="selectpicker" data-live-search="true" runat="server">
                <option value="1">Option 1</option>
                <option value="2">Option 2</option>
                <option value="3">Option 3</option>
                <option value="4">Option 4</option>
                <option value="5">Option 5</option>
            </select>
        </div>
    </form>
</body>
</html>

測試正常

表示 jQuery、bootstrap、bootstrap-select.要某些版本組合才可正常運作。

而 bootstrap-select 1.13.18 說只要 jQuery >= 1.9.1 && < 4.0.0 和 bootstrap >= 3.0.0 ,實際測試不行。


(完)

相關

[研究]ASP.NET,WebForm,試用 Chosen 1.2.0 套件,下拉選單關鍵字過濾顯示

[研究]ASP.NET,WebForm,試用 Chosen 1.2.0 套件,下拉選單關鍵字過濾顯示

2024-05-06

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

https://github.com/prabirshrestha/chosen
https://github.com/prabirshrestha/chosen/tags
prabirshrestha 的 Chosen,目前最新1.2.0版,NuGet提供安裝

https://github.com/harvesthq/chosen
Harvesthq 的 Chosen,目前最新1.8.7版,NuGet不提供安裝

https://github.com/prabirshrestha/chosen/blob/master/LICENSE.md
授權 MIT






********************************************************************************



********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript"src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <%--<link href="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.min.css" rel="stylesheet" />
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"></script>--%>
    <link href="Content/chosen.css" rel="stylesheet" />
    <script type="text/javascript" src="Scripts/chosen.jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.chosen-select').chosen();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:DropDownList ID="ddlOptions" CssClass="chosen-select" runat="server">
                <asp:ListItem Text="Option 1" Value="1"></asp:ListItem>
                <asp:ListItem Text="Option 2" Value="2"></asp:ListItem>
                <asp:ListItem Text="Option 3" Value="3"></asp:ListItem>
                <asp:ListItem Text="Option 4" Value="4"></asp:ListItem>
                <asp:ListItem Text="Option 5" Value="5"></asp:ListItem>
            </asp:DropDownList>
        </div>
    </form>
</body>
</html>


********************************************************************************

兩者實際測試,都可以用。


(完)

相關

2024年5月8日 星期三

[研究]ASP.NET,WebForm,試用 Selectize.js 0.12.1 套件,下拉選單關鍵字過濾顯示

[研究]ASP.NET,WebForm,試用 Selectize.js 0.12.1 套件,下拉選單關鍵字過濾顯示

2024-05-06

環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C# + SQL Server 2019 + SQL Server Management Studio (SSMS) 19

********************************************************************************

https://github.com/selectize/selectize.js
授權 Apache-2.0

GitHub 上最新0.15.2,但 NuGet 上最新 0.12.1

https://github.com/selectize/selectize.js/releases



雖然沒有顯示相依 jQuery 套件,實際測試需要。

另外 selectize.min.js 必須使用 standalone 版本才行。

********************************************************************************

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/Selectize/css/selectize.css" rel="stylesheet" />
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script type="text/javascript" src="Content/Selectize/js/standalone/selectize.min.js"></script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" Width="100px">
            <asp:ListItem Text="--請選擇--" Value=""></asp:ListItem>
            <asp:ListItem Text="選項1" Value="1"></asp:ListItem>
            <asp:ListItem Text="選項2" Value="2"></asp:ListItem>
            <asp:ListItem Text="選項3" Value="3"></asp:ListItem>
            <asp:ListItem Text="選項4" Value="4"></asp:ListItem>
        </asp:DropDownList>
        <br />
        <asp:DropDownList ID="DropDownList2" runat="server" Width="100px">
            <asp:ListItem Text="--請選擇--" Value=""></asp:ListItem>
            <asp:ListItem Text="選項1" Value="1"></asp:ListItem>
            <asp:ListItem Text="選項2" Value="2"></asp:ListItem>
            <asp:ListItem Text="選項3" Value="3"></asp:ListItem>
            <asp:ListItem Text="選項4" Value="4"></asp:ListItem>
        </asp:DropDownList>
    </form>
 <script type="text/javascript">
     $(document).ready(function () {
         // 使用 Selectize.js 初始化 DropDownList
         $('#<%= DropDownList1.ClientID %>').selectize({
                create: false, // 禁止創建新選項
                sortField: 'text', // 按文本排序
                searchField: ['text'], // 搜索字段為文本
                dropdownParent: 'body' // 下拉框父元素
            });
        });
 </script>
 <script type="text/javascript">
     $(document).ready(function () {
         $('#<%= DropDownList2.ClientID %>').selectize();
     });
 </script>
</body>
</html>



********************************************************************************

改用 CssClass 方式執行會失敗

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs"
    Inherits="WebApplication1.Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/Selectize/css/selectize.css" rel="stylesheet" />
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script type="text/javascript" src="Content/Selectize/js/standalone/selectize.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.selectize-input').selectize();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" CssClass="selectize-input" Width="150px">
            <asp:ListItem Text="--請選擇--" Value=""></asp:ListItem>
            <asp:ListItem Text="選項1" Value="1"></asp:ListItem>
            <asp:ListItem Text="選項2" Value="2"></asp:ListItem>
            <asp:ListItem Text="選項3" Value="3"></asp:ListItem>
            <asp:ListItem Text="選項4" Value="4"></asp:ListItem>
        </asp:DropDownList>
    </form>

</body>
</html>



********************************************************************************

改用 CssClass 方式執行成功,可能 CssClass 的名稱不能有減號

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default2.aspx.cs"
    Inherits="WebApplication1.Default2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/Selectize/css/selectize.css" rel="stylesheet" />
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script type="text/javascript" src="Content/Selectize/js/standalone/selectize.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $('.selectizeCss').selectize();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:DropDownList ID="DropDownList1" runat="server" CssClass="selectizeCss" Width="150px">
            <asp:ListItem Text="--請選擇--" Value=""></asp:ListItem>
            <asp:ListItem Text="選項1" Value="1"></asp:ListItem>
            <asp:ListItem Text="選項2" Value="2"></asp:ListItem>
            <asp:ListItem Text="選項3" Value="3"></asp:ListItem>
            <asp:ListItem Text="選項4" Value="4"></asp:ListItem>
        </asp:DropDownList>
    </form>

</body>
</html>



********************************************************************************


********************************************************************************

但2024-05-21補

[研究]ASP.NET, 套件 Select2.js 4.0.13 與 selectize 0.12.1 共存測試https://shaurong.blogspot.com/2024/05/aspnet-select2js-4013-selectize-0121.html

selectize 套件至少要有一個選項,不是靠 DataSourceID 選出來的,否則會沒有「關鍵字過濾」功能。例如下面:

        <asp:DropDownList ID="DropDownList2" Width="150px" runat="server" AutoPostBack="True" 
            AppendDataBoundItems="True"
            DataSourceID="SqlDataSource1" DataTextField="Fruit" DataValueField="Fruit">
            <asp:ListItem Text="--請選擇--" Value=""></asp:ListItem>
        </asp:DropDownList>

********************************************************************************

(完)

相關