Search Funtion when use Chinese-Input tools

Search Funtion when use Chinese-Input tools

jansongjansong Posts: 6Questions: 0Answers: 0
edited May 2013 in DataTables 1.9
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~

Replies

  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin
    edited May 2013
    Is there an event that is fired when he completed character is inserted? At the moment DataTables listens for keyup, which is what is causing the problem you you need multi-key input. If there is an event for that, a listener could be bound to it.

    Allan
  • jansongjansong Posts: 6Questions: 0Answers: 0
    When I copy Chinese-Characters to the Searchbox, DataTables works. It means DataTables support Chinese. So only when i use input-tools to input infomation, it does not work.
    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~
  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin
    edited May 2013
    > Can you show me the search api

    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
  • jansongjansong Posts: 6Questions: 0Answers: 0
    Dear 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!
  • ssy341ssy341 Posts: 15Questions: 0Answers: 0
    @jansong
    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'
  • jansongjansong Posts: 6Questions: 0Answers: 0
    @allan , @ssy341 ,
    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?
  • allanallan Posts: 63,386Questions: 1Answers: 10,449 Site admin
    You'd need to modify the code in the plug-in to apply the same action to each.

    Allan
  • jansongjansong Posts: 6Questions: 0Answers: 0
    Hi 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]
  • jansongjansong Posts: 6Questions: 0Answers: 0
    Dear Allan,
    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~~
This discussion has been closed.