2014-01-30 130 views
0

我爲我的應用程序使用了數據表,我使用了服務器端分頁[JSP-Struts-2],我在特殊字符搜索問題上經歷了不同的線程。仍然我無法弄清楚。普通的英文文本搜索工作正常..請讓我知道需要做的變化,以便進行特殊的字符搜索。Jquery datatables服務器端用特殊字符處理(例如:

請找我的代碼如下..

$(document).ready(function(){ 

         oTable = $('#example').dataTable({ 
          "bJQueryUI": true, 
          "bPaginate": true, 
          "bServerSide": true, 
          "sAjaxSource": "ajaxUserSearch.action", 
          "bProcessing": true, 
            "bLengthChange": false,        
          "oLanguage": { 
          "sUrl": '<s:text name="datatables.msgs"/>' 
           }, 

            "aoColumnDefs": [ 
     { 
      "aTargets":[0], 

      "fnCreatedCell": function(nTd, sData, oData, iRow, iCol) 
      { 
       $(nTd).css('text-align', 'center'); 
      }, 
      "mData": null, 
      "mRender": function(data, type, full) { // You can use <img> as well if you want 
      //console.log(full[7]); 
      if(full[7]=='ACTIVE' || full[7]=='Active') 
          { 
           return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',2)" /> <td>'; 
          } 
          else{ 
           return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',1)" /> <td>'; 
          } 

      }, 

      } 

    ] 
         }); 
           oTable.fnSetColumnVis(9, false); 

        }); 

回答

0

IN THE SERVER_processing.php FIND:

mysql_select_db($gaSql['db'], $gaSql['link']) or 
    die('Could not select database '. $gaSql['db']); 

後添加

//To send utf8 data to MySql - needed if you need to inject utf8 data for search 
    mysql_query("SET character_set_client=utf8", $gaSql['link']); 
    mysql_query("SET character_set_connection=utf8", $gaSql['link']); 

//To read utf8 data from MySql - needed if your result set contains utf8 data 
    mysql_query("SET character_set_results=utf8", $gaSql['link']);