jQWidgets Forums
jQuery UI Widgets › Forums › Grid › encoding utf8 grid problem
Tagged: datagrid, php datagrid
This topic contains 4 replies, has 2 voices, and was last updated by f4b10 12 years, 5 months ago.
-
Author
-
Hi to everyone!
i have a problem with encoding of data. I’ve created a grid like this
var url = "requestpage.php?q=getLocaliFromCity&e="+ $(this).attr('value'); // prepare the data var source = { datatype: "json", datafields: [ { name: 'name' }, { name: 'creatoda' } ], id: 'id', url: url, root: 'data' }; var dataAdapter = new $.jqx.dataAdapter(source); $("#grid").jqxGrid({ width: 670, source: dataAdapter, columnsresize: true, columns: [ { text: 'Nome', dataField: 'nome', width: 100, cellsalign: 'right' }, { text: 'Creato Da', dataField: 'creatoda', width: 100 } ] });
This call a functions in server page .php that return json data, but they are not converted to utf8 correctly
{"data":[{"nome":"Mu Caf\u00e8","creatoda":"Pallo"},{"nome":"Tofi\u00e0","creatoda":"Pallo"
}]}
i don’t know why!
i’m expect this!
{"data":[{"nome":"Mu Cafè","creatoda":"Pallo"},{"nome":"Tofià","creatoda":"Pallo"
}]}
My html page is encoded with utf-8 also the mysql tables and the php connection.
Any solutions?
Thanks!
Hi f4b10,
For integration with PHP, see this help topic: bind-jquery-grid-to-mysql-database-using-php.htm.
For changing the encoding, you need to set the jqxDataAdapter’s contentType setting. For more information, read here: jquery-data-adapter.htm. You would also have to specify the charset on the server.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comit’s not the solution…
i’ve already read the documentation. It’s return
{"data":[{"nome":"Mu Caf\u00e8","creatoda":"Pallo"},{"nome":"Tofi\u00e0","creatoda":"Pallo"}]}
The charset on my server is the default. i have put it inside the connection.php file
$db->query("Set character_set_connection=utf8");
$db->query("Set character_set_results=utf8");
$db->query("Set character_set_client=utf8");
/code>Hi f4b10,
What about the contentType: contentType: “application/json; charset=utf-8”. Have you tried it?
Did you set the PHP header on your server to: header(‘Content-Type: text/html; charset=utf-8’);?Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comSolved!
i’ve mistake the names of columns from “nome” to “name”
i’m sorry to everyone! its work correctly! All settings are right!
Thanks Peter!
-
AuthorPosts
You must be logged in to reply to this topic.