Special Character

QuestionsSpecial Character
Jorge asked 6 years ago

Hi from Spain,

We have a problem with the special characters in our grid.

I'm going to try explain it.

If I create a new record in our grid, and we write some character like for example "España" or "30 €" or "Informática"

This special characters are stored in our Database like "España", "30 €", "Informáica"

We would like that this data, store in the database like the first example.

I have seen a similar issue (https://phpgrid.desk.com/customer/portal/questions/5700458-trouble-reading-portuguese-characters-from-mysql) but I don't know what is its resolution.

Sorry for my english

Best regards.

2 Answers
Abu Ghufran answered 6 years ago

Hello,

Emailed you a working code, and steps to changes. I've tested and verified it's working.

step1: add events in grid config, where $g = new jqgrid();

$e = array();
$e["on_update"] = array("update_client", null, true);
$e["on_data_display"] = array("filter_display", null, true);
$g->set_events($e);

function update_client($data)
{
foreach($data["params"] as $k=>$d)
{
$data["params"][$k] = htmlentities($data["params"][$k],ENT_QUOTES,'utf-8');
}
}

function filter_display($data)
{
foreach($data["params"] as &$d)
{
foreach($d as $k=>$v)
$d[$k] = html_entity_decode($d[$k]);
}
}

step2: Edit jqgrid_dist.php and comment out following lines.

if (isset($_POST['oper']))
{
$op = $_POST['oper'];
$data = $_POST;
$pk_field = $this->options["colModel"][0]["index"];

// fix for dialog edit v/s inline edit
$id = (isset($data[$pk_field])?$data[$pk_field]:$data["id"]);

// fix for mssql utf8 fix
// if (strpos($this->db_driver,"mssql") !== false)
// $data = array_utf8_decode_recursive($data);

// formatters array for k->v
$is_numeric = array();

Sample test code which i made here is attached.

Jorge answered 6 years ago

Hi, there is somebody here?

Your Answer

18 + 3 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?