首页 > 解决方案 > Does YADCF multi_select work with custom_select initialized via initSelectPluginCustomTriggers

问题描述

Having same issue as in thread below but I didn't want to comment on a 2 year old question.

yadcf - custom_select selectize bizarre behavior

I am using yadcf filter type multi select and I am trying to Initialise bootstrap_select as a custom_ select plugin. The custom select is being created fine but I am having the following issues: On page load it looks like this. When you select an option, it duplicates the two list boxes each time like this. See code below. Note: I am using the most recent version of yadcf.

    var _bootstrapselect;
    yadcf.initSelectPluginCustomTriggers(
        function ($filterSelector) {
            _bootstrapselect = $filterSelector.selectpicker({});
        },
        function ($filterSelector) {
            _bootstrapselect.selectpicker('refresh');
        },
        function ($filterSelector) {
            _bootstrapselect.selectpicker('destroy');
        });

Is there any solution to this issue or is it yet to be resolved.

标签: datatablesbootstrap-multiselectyadcf

解决方案


我能够自己解决这个问题。有关尝试将 bootstrap_select 与 yadcf custom_select 一起使用的任何人,请参见下文。

像下面这样初始化 initSelectPluginCustomTriggers。

    var _bootstrapselect;
    yadcf.initSelectPluginCustomTriggers(
        function ($filterSelector) {
            _bootstrapselect = $filterSelector.selectpicker({});
        },
        function ($filterSelector) {
            _bootstrapselect.selectpicker('refresh');
        },
        function ($filterSelector) {
            _bootstrapselect.selectpicker('destroy');
        });  

对于使用 multi_select 的列,如下所示:

    yadcf.init(table, [
        {
            column_number: 0,
            filter_container_id: 'external_filter_container_0',
            filter_type: 'multi_select',
            select_type: 'custom_select',
            style_class: 'selectpicker',
            filter_default_label: 'Filter Value',
            filter_reset_button_text: false,
        }
    ]);

我只是错过了第 0 列中的样式类“selectpicker”。愚蠢。

有关可在 initSelectPluginCustomTriggers 中用于初始化、刷新和销毁功能的更多引导选择方法,请参见此处。


推荐阅读