add a function to search input before search start ,
add a function to search input before search start ,
hi , i want to change my input numbers to persian before my datatable search start , i write the function , but i don't know where should i place it , my function always work after datatable search the table , and i should click on the input again to see the rows that show my answear , for simplicity of my question , how could i add a function to datatable before its original search function start , srry for the bad english
This question has an accepted answers - jump to answer
Answers
Do you mean as the user is typing you are converting Roman numerals to Persian? And you want that to happen before DataTables’ search starts? Your best option is probably to use your own
input
element with aninput
event handler that does your conversion and then triggers a call to thesearch()
method (instead of typing to modify the build in search box).Allan
thanks for the answer , i search for the input in the source code for three days and i couldnt do any thing do it , but your solution seem to work for me , thanks again ,
your solution work for me ,
first we should remove the default search input from data table dom by removing f ,
then add our custom input like
and then in the script add ,
var table1=$('#example1').DataTable({
"dom": '<"top"i>rt<"bottom"lp><"clear">',
});
$("#mySearchText1").bind("keyup", function(e) {
let map = {
'0' : "۰",
'1' : "۱",
'2' : "۲",
'3' : "۳",
'4' : "۴",
'5' : "۵",
'6' : "۶",
'7' : "۷",
'8' : "۸",
'9' : "۹"
};
, thanks for your help allan