简体   繁体   中英

using onChange with yadcf dropdown selects

I am using yadcf ( https://github.com/vedmack/yadcf ) to do some cumulative filtering on my datatables project.

I would like to know if there is a way to capture the value and the index of the selected option in the yadcf select control. For instance, if the user selects 'yxz' in the dropdown, I would like to use some sort of onChange event to capture the value and the index of the selected option.

my yadcf init is:

yadcf.init(table,
            [
                {
                    column_number : 2,
                    filter_container_id: 'headergroupFltr',
                    filter_type: 'select',
                    filter_default_label: "Select Head Group",
                    filter_reset_button_text: false,
                    select_type: 'select2',
                    style_class:"form-control"
                },
                {
                    column_number : 3,
                    filter_container_id: 'subgroupFltr',
                    filter_type: 'select',
                    filter_default_label: "Select Sub Group",
                    filter_reset_button_text: false,
                    select_type: 'select2',
                    style_class:"form-control"
                }],
            { cumulative_filtering: true ,
              filter_match_mode: "exact" }
        );

thank you for your help

You can capture the value as follows:

$('#_select').on('change', function () {
  console.log("changed");
  var selectedTypeIds = yadcf.exGetColumnFilterVal(logTable, 3);
  console.log("selected", selectedTypeIds);
});

Docs

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