Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
441 views
in Technique[技术] by (71.8m points)

html - Select2 with Datatable

I have the following html code which is initialized by the jquery select2 custom script. However my filtering using this select option is not working. I am not sure where the error is.

                    <div class="col-auto">
                    <!-- Select -->
                    <select class="js-select2-custom" size="1" style="opacity: 0;"
                            data-target-column-index="1"
                            data-hs-select2-options='{
                  "minimumResultsForSearch": "Infinity",
                  "customClass": "custom-select custom-select-sm custom-select-borderless",
                  "dropdownAutoWidth": true,
                  "width": true
                }' >
                        <option value="">Any</option>
                        <option value="Accountant">Accountant</option>
                        <option value="Co-founder">Co-founder</option>
                        <option value="Designer">Designer</option>
                        <option value="Developer">Developer</option>
                        <option value="Director">Director</option>
                    </select>
                    <!-- End Select -->
                </div>


<script src="~/front-dashboard-v1.1/dist/assets/vendor/select2/dist/js/select2.full.min.js"></script>
<link href="~/front-dashboard-v1.1/dist/assets/vendor/select2/dist/css/select2.min.css" rel="stylesheet" />
<script src="~/front-dashboard-v1.1/src/assets/js/hs.datatables.js"></script>
<script src="~/front-dashboard-v1.1/dist/assets/vendor/datatables/media/js/jquery.dataTables.js"></script>
<script>
    $(document).on('ready', function () {
        $.HSCore.components.HSDatatables.init($('.js-datatable'));

        // INITIALIZATION OF SELECT2
        // =======================================================
        $('.js-select2-custom').each(function () {
            var select2 = $.HSCore.components.HSSelect2.init($(this));
        });


        var element = document.getElementById("datatableWithSearch");
        element.style.display = null;

        if ($(this).find('tbody tr').length <= 1) {
            $('.js-datatable').parents('div.card').first().hide(-1);
        }
    });

</script>
question from:https://stackoverflow.com/questions/66062905/select2-with-datatable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...