Restrict the first column filter to the first four chars
Restrict the first column filter to the first four chars
m75sa
Posts: 132Questions: 30Answers: 0
Hi,
considering this example:
https://datatables.net/examples/api/multi_filter_select.html
I don't know how to restrict the filter string length of the first column only to the first 4 chars...
I saw that the select options menu item is the same for all the column... so i'm wondering if i change the first one the will change also the others...
Any help on this?
This question has an accepted answers - jump to answer
Answers
On line 5 the API for the particular column is gotten, ie,
var column = this;
. You can usecolumn().index()
to get the column index. Maybe addvar colIndex = column.index();
belowvar column = this;``.
If the index is
0
, the first column, you will need to use a different regex expression in this statement:The regex expression you use will be specific to your requirements but it might be as simple as removing the `+'$'.
Next you might want to change the select options value to only be 4 characters if the column index is 0, ie, this code:
Kevin