EasyUI Forum
May 22, 2024, 09:09:54 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Problem SPECIAL CHARS in datagrid  (Read 5621 times)
rannacher
Jr. Member
**
Posts: 52


View Profile
« on: August 04, 2015, 07:51:24 AM »

Gents, pls need your help!
I appreciate the whole easyUI toolbox and got it functional fast and in depth with the perfect doc available online.

BUT one annoying point for me which prevents me from full happiness is the lack of clarity for SPECIAL CHARACTERS.

Please advise what to do on serverside PHP on what to do on javascript for datagrid data side for properly data masking.

(PS: in mysql the data is fine)

I have to deal with special German chars like ÄÜÖäüöß etc but the problem is also in general as I get the data
also messed up with spaces and other normal special chars. CAN I RUN ONE FUNCTION in php and JS before load
that can HANDLE ALL THE CODING and ENCODING in one central place each?

Among thousand other attemps I tried the below ones in PHP and javascript:

PHP
Code:
function umlaute($text)
{
    $returnvalue="";
    for($i=0;$i<strlen($text);$i++){
        $teil=hexdec(rawurlencode(substr($text, $i, 1)));
        if($teil<32||$teil>1114111){
            $returnvalue.=substr($text, $i, 1);
        }else{
            $returnvalue.="&#".$teil.";";
        }
    }
    return $returnvalue;
}


JS
Code:
  function mydecode(str) 
  {
    var dummy = document.createElement('textarea');
    dummy.innerHTML = str;
    return dummy.value;         
  }


Thanks for your help.

PS: maybe an entry in the doc for this topic to clarify once and for all would be appreciated as well.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: August 04, 2015, 06:26:47 PM »

You can use the 'formatter' function to convert the original data to the expected value.
Code:
{field:'f1',title:'title1',width:200,
formatter:function(value,row){
var v = ...  // convert value to expected result
return v;
}
}
Logged
rannacher
Jr. Member
**
Posts: 52


View Profile
« Reply #2 on: August 05, 2015, 03:25:57 PM »

Thx for help.
Unfortunately this does not solve the problem as the special chars appear different in various locatinos.

F.e. they are fine in datagrid after loading.
They are also fine in combobox/editor but when I select value then I get mixed up text displayed.

Also it depend how you encode on PHP side and decode on JS side (when loading data) or
vice versa how you encode on JS (for insert/update) and decode on PHP side for the SQL execution.

Any rules what PHP/JS functions to use that work with datagrid and editors/combobox/textbox etc?

It is such a great framework where I have such big and functional application now and I really get stuck on this stupid matter only.
Appreciate your kind help again.
Thx in advance!

BR Mike.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!