Adam Dulson
Adam Dulson

Reputation: 283

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

Upvotes: 0

Views: 180

Answers (1)

Matthew Hegarty
Matthew Hegarty

Reputation: 4306

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

Upvotes: 0

Related Questions