Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
944 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...