Bootstrap表按多列筛选

问题描述 投票:2回答:1

我正在使用wenzhixin的Bootstrap Table。我需要按几列过滤。例如,我需要过滤国家,然后过滤城市。

我有两个选择字段用于表中的每个字段(选择国家和选择城市)。

我现在这样做的方法是在更改select选项时应用filterBy方法:

    $('#countries-list').on('change', function (evt) {
        var selectedCountry = $('#countries-list').select2('val');
        if (selectedCountry == "all") {
            $tableFilter.bootstrapTable('filterBy');
        } else {
            $tableFilter.bootstrapTable('filterBy', {country: selectedCountry});                
        }
    });

    $('#cities-list').on('change', function (evt) {
        var selectedCity = $('#cities-list').select2('val');
        if (selectedCity == "all") {
            $tableFilter.bootstrapTable('filterBy');
        } else {
            $tableFilter.bootstrapTable('filterBy', {city: selectedCity});              
        }
    });

问题是他们互相覆盖。我将不胜感激任何有关如何仅将第二个过滤器应用于第一个过滤器的结果的建议,而不是整个数据集。

谢谢!

bootstrap-table
1个回答
1
投票

我建议你使用bootstrap-table扩展名Filter-Control。

© www.soinside.com 2019 - 2024. All rights reserved.