onclick event not work with multi_select filter - javascript

≡放荡痞女 提交于 2019-12-12 04:56:25

问题


I read docs here for filter_type but I don't understand how provide thiese arguments

  • onclick event
  • label.lightblue (or label2.lightblue2..)

for yadcf.exFilterColumn if I want to set

filter_type: "multi_select":
select_type: 'select2'

My code is this:

 $('#example').on('click', ".label.lightblue", function () {

        yadcf.exFilterColumn(oTable, [
            [5, $(this).text()]
        ]);
  });

This is my table: Live Demo
Look last column, please. If you click on a tag inside row table you can filtering rows. I change filter_type from auto_complete to multi_select

column_number: 5,
column_data_type: "html",
html_data_type: "text",
filter_default_label: "Select tag",
filter_type: "multi_select":
select_type: 'select2'

But if you click now on tags inside table rows onclick event functions don't work anymore for column 5, look this example: ONCLICK EVENT freezing

I try to change

yadcf.exFilterColumn(oTable, [[5, $(this).text()]]);

into

yadcf.exFilterColumn(oTable, [[5, ['click','label.lightblue']]]);

but don't work


回答1:


I will ignore your question because I'm not sure why you ended up trying the stuff you wrote there

The difference in your current scenario in which you want to trigger multi selct filter from the table row itself is that now instead of providing the text of the clicked element you need to provide an array with a single value which is that text you are familiar with, BUT if you want to make the click on row to add selections to your filters so if suppose you click on Tag1 and then on Tag2, you expect to see the filter populated with Tag1 and Tag2 you need to make the following:

Each time you click on the column value (Tag1 / Tag2 / etc, you must extract the current selected value of that column using the yadcf.exGetColumnFilterVal(...) , then add to this array your newly clicked value , and only then call the exFilterColumn function (with the new array that you just constructed.

If you will follow my instruction it should work just fine



来源:https://stackoverflow.com/questions/29169327/onclick-event-not-work-with-multi-select-filter-javascript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!