简体   繁体   English

onclick事件不适用于multi_select过滤器-javascript

[英]onclick event not work with multi_select filter - javascript

I read docs here for filter_type but I don't understand how provide thiese arguments 我在这里阅读了关于filter_type的文档,但我不明白如何提供这些参数

  • onclick event onclick事件
  • label.lightblue (or label2.lightblue2.. ) label.lightblue (或label2.lightblue2 ..

for yadcf.exFilterColumn if I want to set 如果要设置yadcf.exFilterColumn

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 我将filter_type从auto_complete更改为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 但是,如果您现在单击表行中的标签,则onclick事件函数在第5列中不再起作用,请看以下示例: ONCLICK EVENT冻结

onclick冻结

I try to change 我尝试改变

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

into 进入

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

but don't work 但是不工作

I will ignore your question because I'm not sure why you ended up trying the stuff you wrote there 我不会理your您的问题,因为我不确定您为什么最终要尝试在那里写的东西

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: 您要从表行本身触发多选择过滤器的当前方案的不同之处在于,现在不提供单击元素的文本,而是需要提供一个具有单个值的数组,即您熟悉的文本, 如果要单击行以将选择项添加到过滤器中,那么如果假设您先单击Tag1然后在Tag2上单击,则希望看到由Tag1和Tag2填充的过滤器,您需要执行以下操作:

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. 每次单击列值(Tag1 / Tag2 /等)时,都必须使用yadcf.exGetColumnFilterVal(...)提取该列的当前选定值,然后将新单击的值添加到该数组中,然后才调用exFilterColumn函数(带有刚刚构造的新数组。

If you will follow my instruction it should work just fine 如果您按照我的指示进行,应该可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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