【问题标题】:How to show exactly one selected item among all as dropdown title in angular js dropdown multiselect?如何在angular js下拉多选中将所有选定的项目准确显示为下拉标题?
【发布时间】:2016-05-18 10:49:32
【问题描述】:

目前,当我设置 dynamicTitle=true 时。它显示了所有选定的项目,如下图所示。

我希望它只显示项目。我在 source 但找不到怎么做。

有一个选择最大元素数量的选项,但我应该能够选择任意数量的元素,但只显示一个元素作为标题。

和元素

<div title={{model.Base.currentRecord.value.Code.display}} ng-dropdown-multiselect="" ng-class="choosen" options="locations" selected-model="myModel"  extra-settings="settings" translation-texts="{buttonDefaultText: 'Select Districts'}" style="display:table" class="pull-right"></div>

`

                scrollableHeight: '300px',
                closeOnBlur: true,
                dynamicTitle: true,
                scrollable: false,
                displayProp: 'label',
                idProp: 'id',
                externalIdProp: 'id',
                enableSearch: false,
                selectionLimit: 0,
                showCheckAll: true,
                showUncheckAll: true,
                closeOnSelect: false,
                buttonClasses: 'btn btn-default',
                closeOnDeselect: false,
                groupBy: $attrs.groupBy || undefined,
                groupByTextProvider: null,
                smartButtonMaxItems: 1,
                smartButtonTextConverter: angular.noop

`

有人可以帮我举个例子吗?

【问题讨论】:

    标签: angularjs multi-select dropdown


    【解决方案1】:

    仅通过阅读他们网站上的文档,我相信您正在寻找的属性是:

    smartButtonMaxItems : 1
    
    /HTML
    <div ng-dropdown-multiselect="" options="example13data" selected-model="example13model" extra-settings="example13settings"></div>
    
    //JS
    $scope.example13model = [];
    $scope.example13data = [
        {id: 1, label: "David"},
        {id: 2, label: "Jhon"},
        {id: 3, label: "Lisa"},
        {id: 4, label: "Nicole"},
        {id: 5, label: "Danny"}];
    
    $scope.example13settings = {
        smartButtonMaxItems: 3,
        smartButtonTextConverter: function(itemText, originalItem) {
            if (itemText === 'Jhon') {
            return 'Jhonny!';
            }
    
            return itemText;
        }
    };
    

    【讨论】:

    • 不,这不是我想要的。我希望标题应该只包含一个选定的项目,以使下拉大小固定。 “智能按钮文本”功能,定义“按钮上”的最大项目数量。
    • 我没有关注,这正是您所要求的,因为您的图像有 3 个选定的项目如果您设置此属性,则只有一个将显示: smartButtonMaxItems : 1 您引用的标题是什么?
    • 我试过了,但它仍然在下拉列表中显示超过 1 个元素,如图所示。
    • 哥们,这是图片,无法打开下拉菜单,所以我还是不知道你在说什么。请打开一个新的 Angular plunkr 并添加脚本和您的代码:rawgit.com/dotansimha/angularjs-dropdown-multiselect/master/src/…
    猜你喜欢
    • 1970-01-01
    • 2023-04-06
    • 2019-12-01
    • 2022-07-06
    • 1970-01-01
    • 2018-12-27
    • 1970-01-01
    • 2013-01-26
    • 2018-04-05
    相关资源
    最近更新 更多