Bootstrap 表按多列过滤

nys*_*oon 2 bootstrap-table

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

表中的每个字段都有两个选择字段(选择国家/地区和选择城市)。

我现在这样做的方式是在更改选择选项时应用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});              
        }
    });
Run Code Online (Sandbox Code Playgroud)

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

谢谢你!

Pab*_*ado 5

我建议您使用引导表扩展Filter-Control