Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
957 views
in Technique[技术] by (71.8m points)

datatables - Data-Filter Overriding Data-Search Attribute

Using DataTables, I am witnessing a reproduceable issue where the value of the data-filter html attribute is overriding the searchability of the data-search html attribute.

<td data-search="Jared Next" data-order="Jared Next" data-filter="Full-Time DM">
  <div class="mb-2">
    Jared Next
  </div>
  <div class="mb-2 text-muted small" title="Number of total deals posted by DM">
    Posted: 294
  </div>
</td>

When searching by "jared" the row does not appear.

When searching by "full-time dm" the row does appear.

Worth mentioning that the filter works as expected:

I apologize if I've not provided enough code to re-create the issue or if DataTables experts want the whole table.

I can easily provide it all.

question from:https://stackoverflow.com/questions/65924141/data-filter-overriding-data-search-attribute

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The data-search and data-filter attributes are synonyms, in DataTables.

See here for details.

You should use one or the other, but not both at the same time.

Also, from the same doc link as above, in case it is relevant: Make sure the attributes are used consistently for every cell in a column:

In order for the HTML 5 data-* attribute detection and processing to work correctly, all cells in a column must have the same attribute available.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...