简体   繁体   中英

Chaining yadcf multi_select filters together

Is there a way to chain filters together where by filters applied in one column will pre-filter the available filters in other columns? Primarily I'm interested in this from a multi_select standpoint, but it could be universal to all filters types I guess.

For example:

Column 1's data contains:

  1. Oklahoma
  2. Missouri
  3. Utah
  4. Texas
  5. Kansas

Column 2's data contains:

  1. Obama
  2. Romney

From the dataset I know that all Column 1 data that has 'Oklahoma' will always mean that Column 2 will equal 'Romney'. Thus, if I select 'Oklahoma' from a mutli_select, then the drop down for the multi_select for Column 2 should now only show 'Romney'.

Basically, can I pre-filter my filters based on other filters already put in place?

I think you are asking about the cumulative_filtering: true option of yadcf,

See the showcase page and here a code sample:

$(document).ready(function () {
    'use strict';

    var oTable;
    oTable = $('#example').DataTable();

    yadcf.init(oTable,
        [
            {
                column_number : 0,
                filter_type: "multi_select",
                select_type: 'select2'
            }, 
            {
                column_number: 3,
                filter_type: "auto_complete",
                text_data_delimiter: ","
            },
            {
                column_number : 4,
                filter_type: "multi_select",
                select_type: 'select2',
                column_data_type: "html",
                html_data_type: "text",
                filter_default_label: "Select tag"
            }
        ],
        {
            cumulative_filtering: true
        }
    );
});

As you see the cumulative_filtering: true is an object property, an object that that is a third argument of the init function, when using the .yadcf([{...}]) api you should pass that object as a second arument to the .yadcf constractor, like this:

.yadcf([{...}], {cumulative_filtering: true})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM