Search Funtion when use Chinese-Input tools
Search Funtion when use Chinese-Input tools
jansong
Posts: 6Questions: 0Answers: 0
Hi:
DataTables is a wonderful Plugins-tool for me.
Now i have an issue that it maybe not happened in english-speaking countries but it's an common one in China.
In China, we use an Chinese-input tools to input our information. We need to press several letters on keyboard then select the Chinese-Character we need. Before we confirm and select the Chinese-Character, in searchbox that is an alternative Chinese-Character and a Highlight effect (like the effect we select the text on the webpage or MS-Word).
In this situation, the search function seems disabled. Because at this time, the search information is not only characters but also effects.
I want to start the search after i confirm Chinese-Character , not always when i press the keyboard. Please help me how can i do it, Thank you~
DataTables is a wonderful Plugins-tool for me.
Now i have an issue that it maybe not happened in english-speaking countries but it's an common one in China.
In China, we use an Chinese-input tools to input our information. We need to press several letters on keyboard then select the Chinese-Character we need. Before we confirm and select the Chinese-Character, in searchbox that is an alternative Chinese-Character and a Highlight effect (like the effect we select the text on the webpage or MS-Word).
In this situation, the search function seems disabled. Because at this time, the search information is not only characters but also effects.
I want to start the search after i confirm Chinese-Character , not always when i press the keyboard. Please help me how can i do it, Thank you~
This discussion has been closed.
Replies
Allan
Can you show me the search api (I'm sorry I did not find it...)? I want to add a judgement about the search infomation in the keyup event. I think the search information have a scope.
Thank you~
Use fnFilter .
You might be interested in this plug-in: http://datatables.net/plug-ins/api#fnFilterOnReturn - delay filtering until the return is hit.
Allan
Thank you for your reply. I think this api(fnFilterOnReturn) is the best solution for me. But i use it followed by the example from the link, and it didnot worked. It still have a keyup event and didnot judge the enter-key.
Can you give me a detailed example? Thank you!
http://datatables.net/plug-ins/api#fnFilterOnReturn
this api is work wonderful,what‘s your problem?
It is a pity that can't solve my problem.
What is your contact information?
my email is 'keithssy@gmail.com'
I'm sorry that i make a mistake before, and fnFilterOnReturn api is useful for the right-top searchbox. But I still have a question.
As an example in DataTables-1.9.4, DataTables-1.9.4\examples\api\multi_filter.html, in this situation, how can I use this api for each column?
Allan
Thanks for your reply. I'm sorry that i study DataTables for only a few days and i can't understand your means.
I try to modify the html in DataTables-1.9.4 examples(DataTables-1.9.4\examples\api\multi_filter.html). I add my comments in some lines.
Can you help me to point where need to modify advanced? Thank you~
The JS code is below:
[code]
jQuery.fn.dataTableExt.oApi.fnFilterOnReturn = function (oSettings) {
var _that = this;
this.each(function (i) {
$.fn.dataTableExt.iApiIndex = i;
var $this = this;
var anControl = $('input', _that.fnSettings().aanFeatures.f);
anControl.unbind('keyup').bind('keypress', function (e) {
if (e.which == 13) {
$.fn.dataTableExt.iApiIndex = i;
_that.fnFilter(anControl.val());
}
});
return this;
});
return this;
};
var asInitVals = new Array();
$(document).ready(function() {
oTable = $('#example').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
});
//It's already worked in the right-top searchBox.
oTable.fnFilterOnReturn();
//How can i modify this event? fnFilterOnReturn api has no parameter, but for each column we need set the search value.
$("tfoot input").keyup( function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter( this.value, $("tfoot input").index(this) );
} );
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("tfoot input").each( function (i) {
asInitVals[i] = this.value;
} );
$("tfoot input").focus( function () {
if ( this.className == "search_init" )
{
this.className = "";
this.value = "";
}
} );
$("tfoot input").blur( function (i) {
if ( this.value == "" )
{
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
} );
} );
[/code]
I change the tfoot event from keyup to keypress, and judge the enter-key, my issue is solved.
Thank you a lot for your guide and help ~DataTables is really a wonderful tool for me~~